(inet_network): Don't overwrite memory or allow to great last digits.
authordrepper <drepper>
Fri, 11 Feb 2000 18:39:06 +0000 (18:39 +0000)
committerdrepper <drepper>
Fri, 11 Feb 2000 18:39:06 +0000 (18:39 +0000)
inet/inet_net.c

index cdc4d9d..78d22cd 100644 (file)
@@ -66,7 +66,7 @@ again:
                        continue;
                }
                if (base == 16 && isxdigit(c)) {
-                       val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
+                       val = (val << 4) + (tolower (c) + 10 - 'a');
                        cp++;
                        digit = 1;
                        continue;
@@ -75,9 +75,9 @@ again:
        }
        if (!digit)
                return (INADDR_NONE);
+       if (pp >= parts + 4 || val > 0xff)
+               return (INADDR_NONE);
        if (*cp == '.') {
-               if (pp >= parts + 4 || val > 0xff)
-                       return (INADDR_NONE);
                *pp++ = val, cp++;
                goto again;
        }
@@ -85,8 +85,6 @@ again:
                return (INADDR_NONE);
        *pp++ = val;
        n = pp - parts;
-       if (n > 4)
-               return (INADDR_NONE);
        for (val = 0, i = 0; i < n; i++) {
                val <<= 8;
                val |= parts[i] & 0xff;