[or-cvs] r10891: Fix some bugs in ntop/pton. (in tor/trunk: . src/common)

nickm at seul.org nickm at seul.org
Fri Jul 20 16:25:27 UTC 2007


Author: nickm
Date: 2007-07-20 12:25:27 -0400 (Fri, 20 Jul 2007)
New Revision: 10891

Modified:
   tor/trunk/
   tor/trunk/src/common/compat.c
Log:
 r13850 at catbus:  nickm | 2007-07-20 12:25:24 -0400
 Fix some bugs in ntop/pton.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13850] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/common/compat.c
===================================================================
--- tor/trunk/src/common/compat.c	2007-07-20 09:47:15 UTC (rev 10890)
+++ tor/trunk/src/common/compat.c	2007-07-20 16:25:27 UTC (rev 10891)
@@ -834,7 +834,8 @@
       words[i] = (((uint16_t)addr->s6_addr[2*i])<<8) + addr->s6_addr[2*i+1];
     }
     if (words[0] == 0 && words[1] == 0 && words[2] == 0 && words[3] == 0 &&
-        words[4] == 0 && (words[5] == 0 || words[5] == 0xffff) && words[6]) {
+        words[4] == 0 && ((words[5] == 0 && (words[6] || words[7])) ||
+                          (words[5] == 0xffff))) {
       /* This is an IPv4 address. */
       if (words[5] == 0) {
         tor_snprintf(buf, sizeof(buf), "::%d.%d.%d.%d",
@@ -965,7 +966,7 @@
       } else if (*src == ':' && i > 0 && gapPos==-1) {
         gapPos = i;
         ++src;
-      } else if (*src == ':' && i == 0 && src[1] == ':') {
+      } else if (*src == ':' && i == 0 && src[1] == ':' && gapPos==-1) {
         gapPos = i;
         src += 2;
       } else {
@@ -973,7 +974,9 @@
       }
     }
 
-    if (setWords > 8 || (setWords < 8 && gapPos == -1))
+    if (setWords > 8 ||
+        (setWords == 8 && gapPos != -1) ||
+        (setWords < 8 && gapPos == -1))
       return 0;
 
     if (gapPos >= 0) {



More information about the tor-commits mailing list