From 49fa68a7972696f523c301ddce262ac6e223e839 Mon Sep 17 00:00:00 2001
From: Chris Sosnin <k.sosnin@tarantool.org>
Date: Thu, 28 Nov 2019 00:04:40 +0300
Subject: [PATCH] build: GCC warning on strncpy

As long as we are sure, that strlen(sd_unix_path) < sizeof(sa.sun_path)
we can assume that there is always enough space and the path will be
null-terminated. Thus, copy 1 byte less to get rid of the warning.

Closes #4515
---
 src/systemd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/systemd.c b/src/systemd.c
index 6686c3ce0e..c80259f069 100644
--- a/src/systemd.c
+++ b/src/systemd.c
@@ -67,7 +67,7 @@ int systemd_init() {
 		.sun_path = { '\0' }
 	};
 	if (strlen(sd_unix_path) >= sizeof(sa.sun_path)) {
-		say_error("systemd: NOTIFY_SOCKET is longer that MAX_UNIX_PATH");
+		say_error("systemd: NOTIFY_SOCKET is longer than MAX_UNIX_PATH");
 		goto error;
 	}
 	if ((systemd_fd = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) {
@@ -117,7 +117,7 @@ int systemd_notify(const char *message) {
 		.sun_family = AF_UNIX,
 	};
 
-	strncpy(sa.sun_path, sd_unix_path, sizeof(sa.sun_path));
+	strncpy(sa.sun_path, sd_unix_path, sizeof(sa.sun_path) - 1);
 	if (sa.sun_path[0] == '@')
 		sa.sun_path[0] = '\0';
 
-- 
GitLab