Use inet_aton to parse IPv4 numbers. This allows e.g. gethostbyname
authordrepper <drepper>
Thu, 29 Apr 1999 12:17:03 +0000 (12:17 +0000)
committerdrepper <drepper>
Thu, 29 Apr 1999 12:17:03 +0000 (12:17 +0000)
to accept "10.1234".

nss/digits_dots.c

index 944b328..9a8d499 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by H.J. Lu <hjl@gnu.ai.mit.edu>, 1997.
 
            {
              if (!*cp)
                {
-                 if (*--cp == '.') break;
+                 int not_ok;
+
+                 if (*--cp == '.')
+                   break;
 
        /* All-numeric, no dot at the end. Fake up a hostent as if
           we'd actually done a lookup.  What if someone types
           255.255.255.255?  The test below will succeed
           spuriously... ???  */
-                 if (inet_pton (af, name, host_addr) <= 0)
+                 switch (af)
+                   {
+                   case AF_INET:
+                     not_ok = inet_aton (name, (struct in_addr *) host_addr);
+                     break;
+                   case AF_INET6:
+                     not_ok = (inet_pton (af, name, host_addr) <= 0);
+                     break;
+                   default:
+                     assert (! "There should be no other `af' value");
+                   }
+                 if (not_ok)
                    {
                      __set_h_errno (HOST_NOT_FOUND);
 #ifndef HAVE_LOOKUP_BUFFER