From: Christian Grothoff Date: Tue, 26 Jun 2012 13:10:45 +0000 (+0000) Subject: -fix error message for unix paths starting with 0-termination X-Git-Tag: initial-import-from-subversion-38251~12810 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3a3e4c0f1b588f687ff98fcee4952fa02e97dfb2;p=oweals%2Fgnunet.git -fix error message for unix paths starting with 0-termination --- diff --git a/src/util/server.c b/src/util/server.c index 1f8c654b5..ff4584677 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -478,10 +478,17 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen) "bind", port, (AF_INET == serverAddr->sa_family) ? "IPv4" : "IPv6"); else if (AF_UNIX == serverAddr->sa_family) - LOG (GNUNET_ERROR_TYPE_WARNING, - _("`%s' failed for `%s': address already in use\n"), "bind", - ((const struct sockaddr_un *) serverAddr)->sun_path); + { + const struct sockaddr_un *un = (const struct sockaddr_un *) serverAddr; + unsigned int off = 0; + if ('\0' == un->sun_path[0]) + off = 1; /* some UNIXPATHs start with 0 */ + LOG (GNUNET_ERROR_TYPE_WARNING, + _("`%s' failed for `%.*s': address already in use\n"), "bind", + (int) ((sizeof (un->sun_path) - off)), + (&un->sun_path[off])); + } } GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock)); errno = eno;