Fix build warning on Tizen 6.0 30/230230/1
authorINSUN PYO <insun.pyo@samsung.com>
Thu, 9 Apr 2020 00:15:37 +0000 (09:15 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Thu, 9 Apr 2020 00:15:37 +0000 (09:15 +0900)
[    8s] In file included from /usr/include/string.h:494,
[    8s]                  from /home/abuild/rpmbuild/BUILD/libsyscommon-4.1/src/libgdbus/dbus-systemd.c:21:
[    8s] In function 'strncpy',
[    8s]     inlined from 'systemd_get_unit_dbus_path' at /home/abuild/rpmbuild/BUILD/libsyscommon-4.1/src/libgdbus/dbus-systemd.c:386:2:
[    8s] /usr/include/bits/string_fortified.h:106:10: warning: '__builtin_strncpy' output truncated before terminating nul copying 31 bytes from a string of the same length [-Wstringop-truncation]
[    8s]   106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));

Change-Id: Iaf5f71d7c364db91b495f50e63005778765ba359

src/libgdbus/dbus-systemd.c

index 4fd961b..54d3857 100644 (file)
@@ -383,7 +383,7 @@ static char *systemd_get_unit_dbus_path(const char *unit)
        if (!path)
                return NULL;
 
-       strncpy(path, SYSTEMD_DBUS_UNIT_PATH, prefix_len);
+       strncpy(path, SYSTEMD_DBUS_UNIT_PATH, prefix_len + 1);
        for (i = 0, p = 0; i <= escape; i++) {
                k = strcspn(unit + p, SYSTEMD_UNIT_ESCAPE_CHAR);
                strncpy(path + prefix_len, unit + p, k);