public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix handling of /etc/hosts and /etc/networks with too long lines
@ 2004-11-23 20:58 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2004-11-23 20:58 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

Hi!

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  <jakub@redhat.com>

	* nss/nss_files/files-XXX.c (internal_getent): If parse_line returned
	-1, also do H_ERRNO_SET (NETDB_INTERNAL).

--- 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
 					  EXTRA_ARGS)));
 
+  if (parse_result == -1)
+    {
+      H_ERRNO_SET (NETDB_INTERNAL);
+      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;
+  return NSS_STATUS_SUCCESS;
 }
 
 

	Jakub

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-11-23 20:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-23 20:58 [PATCH] Fix handling of /etc/hosts and /etc/networks with too long lines Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).