Bugzilla bug #70381: zero the ipv6.ip field after we fail to parse a NSPRPUB_RELEASE_4_1_BRANCH NSPRPUB_RELEASE_4_1_1_BETA3
authorwtc%netscape.com
Wed, 28 Feb 2001 01:00:49 +0000
branchNSPRPUB_RELEASE_4_1_BRANCH
changeset 1757 a58f3f6635519b90271ff3a14fa00d52fc296371
parent 1755 90e5d7331c033fe76e07bad549906d298577e65a
child 1803 fd154be316285685fd369d2ffd7cbc27463eaada
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. (NSPRPUB_RELEASE_4_1_BRANCH)
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)