Fix ASAN issue (stringop-truncation warning) 21/318621/1
authorsooyeon <sooyeon.kim@samsung.com>
Fri, 4 Oct 2024 00:26:10 +0000 (09:26 +0900)
committersooyeon <sooyeon.kim@samsung.com>
Fri, 4 Oct 2024 00:26:10 +0000 (09:26 +0900)
Change-Id: I8ca19125d123c3915dae19dc0f62a10ecc78566f
Signed-off-by: sooyeon <sooyeon.kim@samsung.com>
src/mmi/mmi-node-types.cpp
src/mmi/mmi-port.cpp

index 87993c5db1679d2f615640e7916eaaf49430a8d4..f150db145e05a426822bba942a2078f6de1da0d0 100644 (file)
@@ -214,7 +214,7 @@ int mmi_node_create_custom(const char *custom_type_id, mmi_node_h *node) {
     *node = new mmi_node_s;
     (*node)->type = MMI_NODE_TYPE_CUSTOM;
     (*node)->sub_type = 0;
-    strncpy((*node)->custom_type_id, custom_type_id, MMI_NAME_MAX_LENGTH);
+    strncpy((*node)->custom_type_id, custom_type_id, MMI_NAME_MAX_LENGTH - 1);
     (*node)->custom_type_id[MMI_NAME_MAX_LENGTH - 1] = '\0';
     (*node)->ports = nullptr;
     (*node)->port_count = 0;
index e7bc1ad2e37dc80d4dd865e854d26ffa5714f30e..f2bdda9cf58af4c7771d4d2924bcaf7512a6f4e9 100644 (file)
@@ -247,7 +247,8 @@ MMI_API int mmi_port_clone(mmi_port_h port, mmi_port_h *cloned) {
         return MMI_ERROR_OUT_OF_MEMORY;
     }
 
-    strncpy((*cloned)->name, port_s->name, MMI_NAME_MAX_LENGTH);
+    strncpy((*cloned)->name, port_s->name, MMI_NAME_MAX_LENGTH - 1);
+    (*cloned)->name[MMI_NAME_MAX_LENGTH - 1] = '\0';
     (*cloned)->type = port_s->type;
     (*cloned)->data_type = port_s->data_type;
     (*cloned)->callbacks = port_s->callbacks;