From 2659d3b3afe07942263a78ac907ac814de3032b9 Mon Sep 17 00:00:00 2001 From: Jesus Sanchez-Palencia Date: Tue, 25 Sep 2018 02:31:17 -0700 Subject: Fix gcc 8 build (#74) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * dlt-control-common: Fix build with GCC 8: When the "stringop-truncation" warning is treated as an error, the build fails with the following message: * dlt-control-common.c:213:29: error: ‘strncpy’ output may be truncated copying 255 bytes from a string of length 1023 [-Werror=stringop-truncation] On this file we want to truncate the string due to the destination buffer size, so fix the above by using memcpy() instead. * dlt-logstorage-common: Fix build with GCC 8: When the "stringop-truncation" warning is treated as an error, the build fails with the following message: * dlt-logstorage-common.c:313:5: error: ‘strncpy’ specified bound 1024 equals destination size [-Werror=stringop-truncation] In order to avoid truncating and leaving the '\0' byte out, reduce the bound by 1 byte. * systemd/3rdparty: Fix sd-daemon build with GCC 8: When the "stringop-truncation" warning is treated as an error, the build fails with the following message: * sd-daemon.c:453:9: error: ‘strncpy’ specified bound 108 equals destination size. In order to avoid truncating and leaving the '\0' byte out, reduce the bound by 1 byte. Signed-off-by: Jesus Sanchez-Palencia --- systemd/3rdparty/sd-daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'systemd') diff --git a/systemd/3rdparty/sd-daemon.c b/systemd/3rdparty/sd-daemon.c index 763e079..88936d2 100644 --- a/systemd/3rdparty/sd-daemon.c +++ b/systemd/3rdparty/sd-daemon.c @@ -450,7 +450,7 @@ _sd_export_ int sd_notify(int unset_environment, const char *state) { memset(&sockaddr, 0, sizeof(sockaddr)); sockaddr.sa.sa_family = AF_UNIX; - strncpy(sockaddr.un.sun_path, e, sizeof(sockaddr.un.sun_path)); + strncpy(sockaddr.un.sun_path, e, sizeof(sockaddr.un.sun_path)-1); if (sockaddr.un.sun_path[0] == '@') sockaddr.un.sun_path[0] = 0; -- cgit v1.2.1