about summary refs log tree commit diff
path: root/nss/digits_dots.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-04-29 12:18:08 +0000
committerUlrich Drepper <drepper@redhat.com>1999-04-29 12:18:08 +0000
commit16b0f634a020651c15a7e7fec08e57b9d31783fe (patch)
treeffbf68d0476e37a2a8ddbf26630c13e2993bf351 /nss/digits_dots.c
parent2c68584cdd5fdd2ff82292a47410a8602c7c35b5 (diff)
downloadglibc-16b0f634a020651c15a7e7fec08e57b9d31783fe.tar.gz
glibc-16b0f634a020651c15a7e7fec08e57b9d31783fe.tar.xz
glibc-16b0f634a020651c15a7e7fec08e57b9d31783fe.zip
Update.
1999-04-28  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* nss/digits_dots.c: Use inet_aton to parse IPv4 numbers.
	This allows e.g. gethostbyname to accept "10.1234".
	Reported by Alexander V. Lukyanov <lav@long.yar.ru> [PR libc/1096].

	* nss/test-netdb.c (test_hosts): Add test for gethostbyname and
	non quad IPv4 numbers.

	loaded shared object with all loaded objects.  Initialize l_ino
Diffstat (limited to 'nss/digits_dots.c')
-rw-r--r--nss/digits_dots.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/nss/digits_dots.c b/nss/digits_dots.c
index 944b328a1a..9a8d499cbd 100644
--- a/nss/digits_dots.c
+++ b/nss/digits_dots.c
@@ -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.
 
@@ -98,13 +98,27 @@
 	    {
 	      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