r25565: Fix unintended consequence change for IPv6 noticed
authorJeremy Allison <jra@samba.org>
Mon, 8 Oct 2007 02:48:03 +0000 (02:48 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:31:14 +0000 (12:31 -0500)
by Volker. We used to return 0.0.0.0 for the text
address of an uninitialized socket - ensure we
still do so. Once uninitialized address is as
good as any other.
Jeremy.

source/lib/util_sock.c

index f77fcc9968bb5a9a39ed3e06baa79b5cc24de507..d061d73a81871318ab16b9c1461eb37a14291bb1 100644 (file)
@@ -70,7 +70,12 @@ static char *get_socket_addr(int fd)
        socklen_t length = sizeof(sa);
        static char addr_buf[INET6_ADDRSTRLEN];
 
-       addr_buf[0] = '\0';
+       /* Ok, returning a hard coded IPv4 address
+        * is bogus, but it's just as bogus as a
+        * zero IPv6 address. No good choice here.
+        */
+
+       safe_strcpy(addr_buf, "0.0.0.0", sizeof(addr_buf)-1);
 
        if (fd == -1) {
                return addr_buf;