Fix coverity issue(major) 64/174064/2
authorSeonah Moon <seonah1.moon@samsung.com>
Wed, 28 Mar 2018 01:56:28 +0000 (10:56 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Wed, 28 Mar 2018 05:03:28 +0000 (14:03 +0900)
Change-Id: If2730a9c08b449b46cf04734e38448c2bb20dbce

provider-interface/download-provider-interface.c
provider/download-provider-client.c

index 4741c65..52f09ab 100755 (executable)
@@ -1541,7 +1541,7 @@ int dp_interface_get_http_header_field_list(const int id, char ***fields,
                                if (dp_ipc_read(sock, &array_size, extra_size, __FUNCTION__) < 0) {
                                        errorcode = DP_ERROR_IO_ERROR;
                                } else {
-                                       if (array_size <= 0) {
+                                       if (array_size <= 0 && array_size >= SIZE_MAX) {
                                                errorcode = DP_ERROR_NO_DATA;
                                                *length = 0;
                                        } else {
index 1c09ba4..b1d7528 100755 (executable)
 #include <download-provider-plugin-download-agent.h>
 #include <download-provider-smack.h>
 
+#ifndef SIZE_MAX
+#define SIZE_MAX ((size_t) - 1)
+#endif
+
 char *dp_print_state(int state)
 {
        switch (state) {
@@ -1298,7 +1302,7 @@ static int __dp_request_set_info(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info
                                        TRACE_ERROR("there is a confusion waiting raw binary in %s section", dp_print_property(ipc_info->property));
                                        errorcode = DP_ERROR_IO_ERROR;
                                }
-                               if (raw_info != NULL && raw_info->size > 0) {
+                               if (raw_info != NULL && raw_info->size > 0 && raw_info->size < SIZE_MAX) {
                                        unsigned char *recv_raws = (unsigned char *)calloc(raw_info->size, sizeof(unsigned char));
                                        if (recv_raws == NULL) {
                                                TRACE_ERROR("sock:%d check memory length:%d", client->channel, raw_info->size);