From 16b0f634a020651c15a7e7fec08e57b9d31783fe Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Apr 1999 12:18:08 +0000 Subject: Update. 1999-04-28 Andreas Jaeger * 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 [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 --- nss/digits_dots.c | 20 +++++++++++++++++--- nss/test-netdb.c | 5 ++++- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'nss') 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 , 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 diff --git a/nss/test-netdb.c b/nss/test-netdb.c index 7f1a767b4e..358d072a9c 100644 --- a/nss/test-netdb.c +++ b/nss/test-netdb.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger , 1998. @@ -167,6 +167,9 @@ test_hosts (void) hptr1 = gethostbyname ("127.0.0.1"); output_hostent ("gethostbyname (\"127.0.0.1\")", hptr1); + hptr1 = gethostbyname ("10.1234"); + output_hostent ("gethostbyname (\"10.1234\")", hptr1); + hptr1 = gethostbyname2 ("localhost", AF_INET); output_hostent ("gethostbyname2 (\"localhost\", AF_INET)", hptr1); -- cgit 1.4.1