*/
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#define DOWNLOAD_FILENAME_MAX 256
+#ifndef SIZE_MAX
+#define SIZE_MAX ((size_t) -1)
+#endif
+
// define type
typedef struct {
int channel; // query & response
size_t string_length = 0;
*string = NULL;
errorcode = __dp_ipc_response(sock, id, DP_SEC_GET, property, &string_length);
- if (errorcode == DP_ERROR_NONE) {
+ if (errorcode == DP_ERROR_NONE && string_length < SIZE_MAX) {
if (string_length > 0) {
char *recv_str = (char *)calloc((string_length + (size_t)1), sizeof(char));
if (recv_str == NULL) {
size_t string_length = 0;
*value = NULL;
errorcode = __dp_ipc_response(sock, id, section, property, &string_length);
- if (errorcode == DP_ERROR_NONE) {
+ if (errorcode == DP_ERROR_NONE && string_length < SIZE_MAX) {
if (string_length > 0) {
char *recv_str = (char *)calloc((string_length + (size_t)1), sizeof(char));
if (recv_str == NULL) {
size_t string_length = 0;
errorcode = __dp_ipc_response(sock, id, section, property, &string_length);
recv_strings[i] = NULL;
- if (errorcode == DP_ERROR_NONE && string_length > 0) {
+ if (errorcode == DP_ERROR_NONE && string_length > 0 && string_length < SIZE_MAX) {
char *recv_str = (char *)calloc((string_length + (size_t)1), sizeof(char));
if (recv_str == NULL) {
TRACE_ERROR("check memory length:%d", string_length * sizeof(char));