Fix build warning 44/238044/3
authormk5004.lee <mk5004.lee@samsung.com>
Wed, 8 Jul 2020 02:19:13 +0000 (11:19 +0900)
committermk5004.lee <mk5004.lee@samsung.com>
Thu, 9 Jul 2020 02:28:34 +0000 (11:28 +0900)
warning: '__builtin_strncpy' output may be truncated copying 255 bytes from
a string of length 255 [-Wstringop-truncation]

Change-Id: I7610e42fed5dab09a1476bbfdb31ae83d25b4560
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
server/alarm-manager.c

index cb3a325..06c8fd4 100644 (file)
@@ -143,7 +143,7 @@ static bool __get_caller_unique_name(int pid, char *unique_name, int size, bool
                /* When a caller is an application, the unique name is appID. */
                if (is_app)
                        *is_app = true;
-               strncpy(unique_name, caller_appid, size - 1);
+               snprintf(unique_name, size, "%s", caller_appid);
        } else {
                /* Otherwise, the unique name is /proc/pid/cmdline. */
                char *cmdline;
@@ -155,7 +155,7 @@ static bool __get_caller_unique_name(int pid, char *unique_name, int size, bool
                if (!cmdline)
                        return false;
                else
-                       strncpy(unique_name, cmdline, size - 1);
+                       snprintf(unique_name, size, "%s", cmdline);
 
                free(cmdline);
        }