Fix Svace issues 77/151477/2 accepted/tizen/unified/20170926.062038 submit/tizen/20170926.005334
authorjh8801.jung <jh8801.jung@samsung.com>
Thu, 21 Sep 2017 04:15:47 +0000 (13:15 +0900)
committerjh8801.jung <jh8801.jung@samsung.com>
Thu, 21 Sep 2017 05:05:42 +0000 (14:05 +0900)
Signed-off-by: jh8801.jung <jh8801.jung@samsung.com>
Change-Id: I278d2883215b46b1990aa29eeab092464140f43a

packaging/nfc-plugin-emul.spec
src/oem/oem_emul.c

index 8b9b6e2..b11917a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       nfc-plugin-emul
 Summary:    NFC emul plugin
-Version:    0.0.25
+Version:    0.0.26
 Release:    0
 Group:      TO_BE/FILLED_IN
 License:    Apache-2.0
index 8ca646c..c6c915c 100755 (executable)
@@ -485,7 +485,13 @@ static void _net_nfc_initialize_llcp(void)
 
        if (Snep_Server_msg == NULL) {
                Snep_Server_msg = (snep_msg_s *)calloc(1, sizeof(snep_msg_s));
+               if (Snep_Server_msg == NULL)
+                       return;
+
                Snep_Server_msg->data = (data_s *)calloc(1, sizeof(data_s));
+               if (Snep_Server_msg->data == NULL)
+                       return;
+
                Snep_Server_msg->data->buffer = (uint8_t *)calloc(1, sizeof(uint8_t) * BUFFER_LENGTH_MAX);
        }
 
@@ -660,7 +666,7 @@ static int _net_nfc_create_records_from_emulMsg(emulMsg_s *emul_msg, ndef_messag
                        DEBUG_MSG("_nfc_emul_util_alloc_mem failed");
                        goto ERROR;
                }
-               memcpy(record.typeName.buffer, type_name, record.typeName.length);
+               memcpy(record.typeName.buffer, type_name, sizeof(record.typeName.buffer) - 1);
 
                DEBUG_MSG("Data : record_id ");
 
@@ -671,7 +677,7 @@ static int _net_nfc_create_records_from_emulMsg(emulMsg_s *emul_msg, ndef_messag
                        DEBUG_MSG("_nfc_emul_util_alloc_mem failed");
                        goto ERROR;
                }
-               memcpy(record.id.buffer, record_id, record.id.length);
+               memcpy(record.id.buffer, record_id, sizeof(record.id.buffer) - 1);
 
                DEBUG_MSG("Data : record_payload ");
 
@@ -682,7 +688,7 @@ static int _net_nfc_create_records_from_emulMsg(emulMsg_s *emul_msg, ndef_messag
                        DEBUG_MSG("_nfc_emul_util_alloc_mem failed");
                        goto ERROR;
                }
-               memcpy(record.payload.buffer, record_payload, record.payload.length);
+               memcpy(record.payload.buffer, record_payload, sizeof(record.payload.buffer) - 1);
 
 #ifndef __EMUL_DEBUG__
                DEBUG_ERR_MSG("RECORD DATA START >>>>>>>>>>>>>>>>>>>>>>>>");
@@ -832,7 +838,7 @@ static int _net_nfc_create_records_from_emulMsg(emulMsg_s *emul_msg, ndef_messag
                                                _nfc_emul_util_free_mem(filePayload.buffer);
                                                goto ERROR;
                                        }
-                                       memcpy(record.id.buffer, file_name, record.id.length);
+                                       memcpy(record.id.buffer, file_name, sizeof(record.id.buffer) - 1);
                                }
                        } else {
                                DEBUG_MSG("file open error");
@@ -898,7 +904,7 @@ static bool _net_nfc_change_file_owner_permission(FILE *file)
                return false;
 
        /* change permission */
-       fchmod(fileno(file), 0777);
+       fchmod(fileno(file), 0644);
 
        /* change owner */
        /* get passwd id */
@@ -1062,6 +1068,7 @@ static bool _net_nfc_create_ndef_from_emulMsg(emulMsg_s *emul_msg)
        _net_nfc_store_ndef_message(&rawdata);
 
        _nfc_emul_util_free_mem(rawdata.buffer);
+       net_nfc_util_free_ndef_message(ndef_message);
 
        DEBUG_EMUL_END();
 
@@ -1839,6 +1846,9 @@ static bool net_nfc_emul_controller_get_firmware_version(data_s **data, net_nfc_
        (*data)->length = 10;
        (*data)->buffer = (uint8_t *)calloc(1, (*data)->length);
 
+       if ((*data)->buffer == NULL)
+               return false;
+
        snprintf((char *)(*data)->buffer, (*data)->length, "%d.%d", 1, 0);
 
        DEBUG_EMUL_END();
@@ -2991,7 +3001,7 @@ static bool net_nfc_emul_controller_secure_element_send_apdu(net_nfc_target_hand
        if (temp != NULL) {
                temp->buffer = (uint8_t *)calloc(1, length + 1);
                if (temp->buffer != NULL) {
-                       memcpy(temp->buffer, buffer, length);
+                       memcpy(temp->buffer, buffer, sizeof(temp->buffer) - 1);
                        temp->length = length;
 
                        *response = temp;