This is the mail archive of the libc-hacker@sources.redhat.com 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]

[PATCH]: Fix file descriptor leakage in resolver


Untarring the Linux kernel on a system that uses Hesiod for the passwd
and group databases unveiled a file descriptor leakage in the resolver
(typically one per failed getxxbyy() call).  The problem is that
statp->_u._ext.nscount is initialized only once (in
res_send.c:res_nsend()), but a request may be retried, with a call to
res_nclose() in between.  Since statp->_u._ext.nscount is now zero,
sockets used in the retry won't be closed.  The attached patch fixes
the problems.  I'm not exactly sure it's The Right Way to fix the
problem, but it should be sufficient until the BIND folks come up with
something better.

Mark


2000-12-27  Mark Kettenis  <kettenis@gnu.org>

	* resolv/res_init.c (res_nclose): Don't set statp->_u._ext.nscount
	to zero.  This avoids leaking file descriptors on failed name
	server queries.


Index: resolv/res_init.c
===================================================================
RCS file: /cvs/glibc/libc/resolv/res_init.c,v
retrieving revision 1.25
diff -u -p -r1.25 res_init.c
--- res_init.c	2000/09/26 09:44:31	1.25
+++ res_init.c	2000/12/27 17:00:16
@@ -544,5 +544,4 @@ res_nclose(res_state statp) {
 			statp->_u._ext.nssocks[ns] = -1;
 		}
 	}
-	statp->_u._ext.nscount = 0;
 }

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