This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix getent hosts 127.0.0.1


Hi!

Currently getent always passes 16 as second argument to gethostbyaddr,
no matter if for AF_INET6 (correct) or for AF_INET (4 times bigger
than it should be).  This results in getent hosts 127.0.0.1
(or other IPv4 IP) to print nothing even when there is a reverse
entry.

2005-10-08  Jakub Jelinek  <jakub@redhat.com>

	* nss/getent.c (hosts_keys): Pass INADDRSZ as size rather
	than IN6ADDRSZ to AF_INET gethostbyaddr.

--- libc/nss/getent.c.jj	2005-09-09 22:37:44.000000000 -0400
+++ libc/nss/getent.c	2005-10-08 10:50:41.000000000 -0400
@@ -280,9 +280,9 @@ hosts_keys (int number, char *key[])
       char addr[IN6ADDRSZ];
 
       if (inet_pton (AF_INET6, key[i], &addr) > 0)
-	host = gethostbyaddr (addr, sizeof (addr), AF_INET6);
+	host = gethostbyaddr (addr, IN6ADDRSZ, AF_INET6);
       else if (inet_pton (AF_INET, key[i], &addr) > 0)
-	host = gethostbyaddr (addr, sizeof (addr), AF_INET);
+	host = gethostbyaddr (addr, INADDRSZ, AF_INET);
       else if ((host = gethostbyname2 (key[i], AF_INET6)) == NULL)
 	host = gethostbyname2 (key[i], AF_INET);
 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]