]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
silly web server: silent a compilation warning
authorPatrick Monnerat <patrick@monnerat.net>
Tue, 28 Jan 2020 10:56:41 +0000 (11:56 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 8 Mar 2020 16:30:55 +0000 (17:30 +0100)
Recent gcc warns when byte count of strncpy() equals the destination
buffer size. Since the destination buffer is previously cleared and
the source string is always shorter, reducing the byte count by one
silents the warning without affecting the result.

Closes #5059

tests/server/sws.c

index eed2d5fd9155e89db1af3d3fbe895a511a2e6d95..b397ed19bb9ac1a953dcd9e5d3fad6df2fc98053 100644 (file)
@@ -2163,7 +2163,7 @@ int main(int argc, char *argv[])
   case AF_UNIX:
     memset(&me.sau, 0, sizeof(me.sau));
     me.sau.sun_family = AF_UNIX;
-    strncpy(me.sau.sun_path, unix_socket, sizeof(me.sau.sun_path));
+    strncpy(me.sau.sun_path, unix_socket, sizeof(me.sau.sun_path) - 1);
     rc = bind(sock, &me.sa, sizeof(me.sau));
     if(0 != rc && errno == EADDRINUSE) {
       struct stat statbuf;