Author: jra
Date: 2007-10-08 02:48:03 +0000 (Mon, 08 Oct 2007)
New Revision: 25565

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25565

Log:
Fix unintended consequence change for IPv6 noticed
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.

Modified:
   branches/SAMBA_3_2/source/lib/util_sock.c
   branches/SAMBA_3_2_0/source/lib/util_sock.c


Changeset:
Modified: branches/SAMBA_3_2/source/lib/util_sock.c
===================================================================
--- branches/SAMBA_3_2/source/lib/util_sock.c   2007-10-07 17:58:48 UTC (rev 
25564)
+++ branches/SAMBA_3_2/source/lib/util_sock.c   2007-10-08 02:48:03 UTC (rev 
25565)
@@ -70,8 +70,13 @@
        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;
        }

Modified: branches/SAMBA_3_2_0/source/lib/util_sock.c
===================================================================
--- branches/SAMBA_3_2_0/source/lib/util_sock.c 2007-10-07 17:58:48 UTC (rev 
25564)
+++ branches/SAMBA_3_2_0/source/lib/util_sock.c 2007-10-08 02:48:03 UTC (rev 
25565)
@@ -70,8 +70,13 @@
        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;
        }

Reply via email to