]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(inet_network): Don't overwrite memory or allow to great last digits.
authorUlrich Drepper <drepper@redhat.com>
Fri, 11 Feb 2000 17:59:38 +0000 (17:59 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 11 Feb 2000 17:59:38 +0000 (17:59 +0000)
inet/inet_net.c

index b346b63735b31bbb84080d9adae75a563318b0a1..78d22cda6b5f134839565f00535616ead56723db 100644 (file)
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
@@ -70,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;
@@ -79,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;
        }
@@ -89,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;