aboutsummaryrefslogtreecommitdiff
path: root/nss/getent.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-10-19 21:11:32 +0000
committerUlrich Drepper <drepper@redhat.com>2004-10-19 21:11:32 +0000
commit653aeda54916d28b010c1bb2240c962b9d01b6ad (patch)
tree1f640d1462609dc8b18781ab0f5c47f55f257bbd /nss/getent.c
parenta019191bbab9ac595ed1c792fd4bc0e1cadd7411 (diff)
downloadglibc-653aeda54916d28b010c1bb2240c962b9d01b6ad.zip
glibc-653aeda54916d28b010c1bb2240c962b9d01b6ad.tar.gz
glibc-653aeda54916d28b010c1bb2240c962b9d01b6ad.tar.bz2
Update.
2004-10-19 Ulrich Drepper <drepper@redhat.com> * nss/getent.c (hosts_keys): Let inet_pton decide whether the string is an address or not.
Diffstat (limited to 'nss/getent.c')
-rw-r--r--nss/getent.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/nss/getent.c b/nss/getent.c
index f9f0a6e..c0a2732 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -276,19 +276,12 @@ hosts_keys (int number, char *key[])
for (i = 0; i < number; ++i)
{
struct hostent *host = NULL;
+ char addr[IN6ADDRSZ];
- if (strchr (key[i], ':') != NULL)
- {
- char addr[IN6ADDRSZ];
- if (inet_pton (AF_INET6, key[i], &addr))
- host = gethostbyaddr (addr, sizeof (addr), AF_INET6);
- }
- else if (isdigit (key[i][0]))
- {
- char addr[INADDRSZ];
- if (inet_pton (AF_INET, key[i], &addr))
- host = gethostbyaddr (addr, sizeof (addr), AF_INET);
- }
+ if (inet_pton (AF_INET6, key[i], &addr) > 0)
+ host = gethostbyaddr (addr, sizeof (addr), AF_INET6);
+ else if (inet_pton (AF_INET, key[i], &addr) > 0)
+ host = gethostbyaddr (addr, sizeof (addr), AF_INET);
else if ((host = gethostbyname2 (key[i], AF_INET6)) == NULL)
host = gethostbyname2 (key[i], AF_INET);