This is the mail archive of the 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 handling of /etc/hosts and /etc/networks with too long lines


NEED_H_ERRNO is defined just by files-hosts.c, files-parse.c and
nis-hosts.c.  If parse_line fails with -1, it means at least for these
3 that the provided buffer was too small.  parse_list sets *errnop to
ERANGE, but doesn't set *herrnop to NETDB_INTERNAL, because that argument
is not passed to parse_line.  I first modified parse_line, so that
the caller passed H_ERRNO_ARG to it, but then realized that e.g. nss_nis
sets *herrnop explicitely in the caller and it is certainly far simpler
that way.

With this patch, getent hosts works as expected even when some lines
in /etc/hosts contain hundreds of aliases, without it it simply stopped
before first such line.

2004-11-23  Jakub Jelinek  <>

	* nss/nss_files/files-XXX.c (internal_getent): If parse_line returned

--- libc/nss/nss_files/files-XXX.c.jj	2004-11-23 21:42:29.000000000 +0100
+++ libc/nss/nss_files/files-XXX.c	2004-11-23 21:44:56.565734779 +0100
@@ -213,8 +213,14 @@ internal_getent (struct STRUCTURE *resul
 	 || ! (parse_result = parse_line (p, result, data, buflen, errnop
+  if (parse_result == -1)
+    {
+      return NSS_STATUS_TRYAGAIN;
+    }
   /* Filled in RESULT with the next entry from the database file.  */
-  return parse_result == -1 ? NSS_STATUS_TRYAGAIN : NSS_STATUS_SUCCESS;


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