]> mj.ucw.cz Git - libucw.git/commitdiff
- fixed accepted double 0x prefix ("0x0x12345678") and
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Tue, 25 Apr 2006 07:54:00 +0000 (09:54 +0200)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Tue, 25 Apr 2006 07:54:00 +0000 (09:54 +0200)
  negative numbers ("-0.-0.-0.-0") in IP parser

lib/conf2.c

index 900e8e5528c2398ffa2528638677824df3b7a987..7216becd8f03acdf0f753bf4755d08f100e75048 100644 (file)
@@ -555,10 +555,10 @@ cf_parse_ip(byte *p, u32 *varp)
     return "Missing IP address";
   uns x = 0;
   char *p2;
-  if (*p == '0' && p[1] | 32 == 'X') {
+  if (*p == '0' && p[1] | 32 == 'X' && Cxdigit(p[2])) {
     errno = 0;
-    x = strtoul(p + 2, &p2, 16);
-    if (errno == ERANGE || p2 == (char*) (p+2) || x > 0xffffffff)
+    x = strtoul(p, &p2, 16);
+    if (errno == ERANGE || x > 0xffffffff)
       goto error;
     p = p2;
   }
@@ -568,6 +568,8 @@ cf_parse_ip(byte *p, u32 *varp)
        if (*p++ != '.')
          goto error;
       }
+      if (!Cdigit(*p))
+       goto error;
       errno = 0;
       uns y = strtoul(p, &p2, 10);
       if (errno == ERANGE || p2 == (char*) p || y > 255)