aboutsummaryrefslogtreecommitdiff
path: root/nss/nss_files
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-07-01 02:42:59 -0700
committerUlrich Drepper <drepper@redhat.com>2009-07-01 02:42:59 -0700
commit29ba9812bb86bf6da9702f4fbff5cdbb25846401 (patch)
tree80640cc07ed58cf497a77602a28a75b2504c0a17 /nss/nss_files
parente6bd12ddf72412918fe9002a3e27ecc07775bd64 (diff)
downloadglibc-29ba9812bb86bf6da9702f4fbff5cdbb25846401.zip
glibc-29ba9812bb86bf6da9702f4fbff5cdbb25846401.tar.gz
glibc-29ba9812bb86bf6da9702f4fbff5cdbb25846401.tar.bz2
Fix getnetbyaddr implementation.
There were two problems in the getnetbyaddr implementation. The type argument is pretty much useless since (almost) no input file contains this information and the NSS backends make up the value they fill in for the n_addrtype field. Therefore we now declare that passing AF_UNSPEC is always recognized. Secondly, the files backend didn't compare the network numbers with the correct endianess. Also change getent to take advantage of the type parameter change.
Diffstat (limited to 'nss/nss_files')
-rw-r--r--nss/nss_files/files-network.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/nss/nss_files/files-network.c b/nss/nss_files/files-network.c
index 9f4a3e0..064de5a 100644
--- a/nss/nss_files/files-network.c
+++ b/nss/nss_files/files-network.c
@@ -1,5 +1,5 @@
/* Networks file parser in nss_files module.
- Copyright (C) 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1996-1998, 2000, 2001, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -81,7 +81,8 @@ DB_LOOKUP (netbyname, ,,
DB_LOOKUP (netbyaddr, ,,
{
- if (result->n_addrtype == type && result->n_net == net)
+ if ((type == AF_UNSPEC || result->n_addrtype == type)
+ && result->n_net == htonl (net))
/* Bingo! */
break;
}, uint32_t net, int type)