Fix static anlaysis issues 64/154864/1
authorjusung son <jusung07.son@samsung.com>
Wed, 11 Oct 2017 10:07:08 +0000 (19:07 +0900)
committerjusung son <jusung07.son@samsung.com>
Wed, 11 Oct 2017 10:07:08 +0000 (19:07 +0900)
 - Buffer not null terminated
 - Use of untrusted scalar value

Change-Id: I227b50bee304ea5366e9e8719877dff7239c2d0c
Signed-off-by: jusung son <jusung07.son@samsung.com>
src/data_control_provider.c

index 054b7eb..f493df2 100755 (executable)
@@ -695,7 +695,7 @@ static bundle *__set_result(bundle *b, datacontrol_request_type type, void *data
        if (type == DATACONTROL_TYPE_UNDEFINED || type == DATACONTROL_TYPE_ERROR) {
                request_type = bundle_get_val(b, OSP_K_DATACONTROL_REQUEST_TYPE);
                if (request_type)
-                       strncpy(type_str, request_type, MAX_LEN_DATACONTROL_REQ_TYPE);
+                       strncpy(type_str, request_type, MAX_LEN_DATACONTROL_REQ_TYPE - 1);
                _LOGI("type is %s", type_str);
 
        } else {
@@ -1886,6 +1886,11 @@ gboolean __provider_recv_message(GIOChannel *channel,
                        }
 
                        kb = bundle_decode_raw((bundle_raw *)buf, data_len);
+                       if (kb == NULL) {
+                               _LOGE("bundle_decode failed");
+                               goto error;
+                       }
+
                        if (__provider_process(kb, fd, consumer_appid) !=
                                        DATA_CONTROL_ERROR_NONE) {
                                bundle_free(kb);