Skip to content
Snippets Groups Projects
Commit 49fa68a7 authored by Chris Sosnin's avatar Chris Sosnin Committed by Kirill Yukhin
Browse files

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
parent eddc8cc0
No related branches found
No related tags found
No related merge requests found
......@@ -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';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment