-make sure result is 0-terminated for UDS
authorChristian Grothoff <christian@grothoff.org>
Wed, 24 Apr 2013 13:11:09 +0000 (13:11 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 24 Apr 2013 13:11:09 +0000 (13:11 +0000)
src/util/common_logging.c

index cd845cccea3c54711bf2d1df1e6a5144f2ead009..5b355b2e1d570ee3c8a23382c0762075657e7b41 100644 (file)
@@ -1206,7 +1206,8 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen)
     off = 0;
     if (un->sun_path[0] == '\0')
       off++;
-    snprintf (buf, sizeof (buf), "%s%.*s", (off == 1) ? "@" : "",
+    memset (buf, 0, sizeof (buf));
+    snprintf (buf, sizeof (buf) - 1, "%s%.*s", (off == 1) ? "@" : "",
               (int) (addrlen - sizeof (sa_family_t) - 1 - off),
               &un->sun_path[off]);
     return buf;