From: INSUN PYO Date: Thu, 9 Apr 2020 00:15:37 +0000 (+0900) Subject: Fix build warning on Tizen 6.0 X-Git-Tag: submit/tizen/20200429.062821~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=40418d764457e9dcadfe5b666a6afe0b69ff0e1e;p=platform%2Fcore%2Fsystem%2Flibsyscommon.git Fix build warning on Tizen 6.0 [ 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 --- diff --git a/src/libgdbus/dbus-systemd.c b/src/libgdbus/dbus-systemd.c index 4fd961b..54d3857 100644 --- a/src/libgdbus/dbus-systemd.c +++ b/src/libgdbus/dbus-systemd.c @@ -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);