Fix ASAN build issue 46/318846/2 accepted/tizen_9.0_unified accepted/tizen_unified_toolchain accepted/tizen/9.0/unified/20241030.234509 accepted/tizen/unified/20241011.010703 accepted/tizen/unified/toolchain/20241022.122653 accepted/tizen/unified/toolchain/20241022.123056 accepted/tizen/unified/x/20241011.021826 accepted/tizen/unified/x/asan/20241013.235429 tizen_9.0_m2_release
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 10 Oct 2024 01:47:28 +0000 (10:47 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 10 Oct 2024 01:57:36 +0000 (01:57 +0000)
The strncpy with character size of fixed size string still
causes stringop-truncation warning in ASAN build, so resolve
the issue with strncpy of full size including terminated
character.

Change-Id: I09be11b837c3c1ed7f34e48b242bad912cbb92ca
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
src/mmi/mmi-port.cpp

index f2bdda9cf58af4c7771d4d2924bcaf7512a6f4e9..e7bc1ad2e37dc80d4dd865e854d26ffa5714f30e 100644 (file)
@@ -247,8 +247,7 @@ 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 - 1);
-    (*cloned)->name[MMI_NAME_MAX_LENGTH - 1] = '\0';
+    strncpy((*cloned)->name, port_s->name, MMI_NAME_MAX_LENGTH);
     (*cloned)->type = port_s->type;
     (*cloned)->data_type = port_s->data_type;
     (*cloned)->callbacks = port_s->callbacks;