Bugzilla bug #70381: zero the ipv6.ip field after we fail to parse a
authorwtc%netscape.com
Wed, 28 Feb 2001 01:02:45 +0000
changeset 1758 119766608da60a3e0301c96b1d8723a5ee759db3
parent 1756 b3486c73ebef6107934955b7a95e7b42207d8bb6
child 1762 18b433a4b00356d5a73688b316dcd5a41559ba2b
push idunknown
push userunknown
push dateunknown
bugs70381
Bugzilla bug #70381: zero the ipv6.ip field after we fail to parse a string as an IPv6 address. Thanks to Chris Elving for the bug report.
pr/src/misc/prnetdb.c
--- a/pr/src/misc/prnetdb.c
+++ b/pr/src/misc/prnetdb.c
@@ -1418,16 +1418,18 @@ PR_IMPLEMENT(PRStatus) PR_StringToNetAdd
     rv = inet_pton(AF_INET6, string, &addr->ipv6.ip);
     if (1 == rv)
     {
         addr->raw.family = PR_AF_INET6;
     }
     else
     {
         PR_ASSERT(0 == rv);
+        /* clean up after the failed inet_pton() call */
+        memset(&addr->ipv6.ip, 0, sizeof(addr->ipv6.ip));
         rv = inet_pton(AF_INET, string, &addr->inet.ip);
         if (1 == rv)
         {
             addr->raw.family = AF_INET;
         }
         else
         {
             PR_ASSERT(0 == rv);
@@ -1437,16 +1439,18 @@ PR_IMPLEMENT(PRStatus) PR_StringToNetAdd
     }
 #else /* _PR_INET6 */
     rv = StringToV6Addr(string, &addr->ipv6.ip);
     if (1 == rv) {
         addr->raw.family = PR_AF_INET6;
         return PR_SUCCESS;
     }
     PR_ASSERT(0 == rv);
+    /* clean up after the failed StringToV6Addr() call */
+    memset(&addr->ipv6.ip, 0, sizeof(addr->ipv6.ip));
 
     addr->inet.family = AF_INET;
 #ifdef XP_OS2_VACPP
     addr->inet.ip = inet_addr((char *)string);
 #else
     addr->inet.ip = inet_addr(string);
 #endif
     if ((PRUint32) -1 == addr->inet.ip)