From: Ulrich Drepper Date: Thu, 30 Jun 2011 03:33:38 +0000 (-0400) Subject: Avoid write to invalid file descriptor in nscd X-Git-Tag: glibc-2.15~499 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf3b23ffcd95841f1d36a3c808c415b41d70b3a9;p=thirdparty%2Fglibc.git Avoid write to invalid file descriptor in nscd When readding entries to the group and services cache and the lookup is unsuccesful, we tried to write the notfound record. Just don't do it in this case. --- diff --git a/ChangeLog b/ChangeLog index b4d30ca33a4..16187bb0874 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-06-29 Ulrich Drepper + + * nscd/grpcache.c (cache_addgr): Don't write notfound reply if we + are re-adding the entry. + * nscd/servicescache.c (cache_addserv): Likewise. + 2011-06-28 Ulrich Drepper [BZ #12935] diff --git a/nscd/grpcache.c b/nscd/grpcache.c index fa219290149..0e7f81f5355 100644 --- a/nscd/grpcache.c +++ b/nscd/grpcache.c @@ -114,8 +114,9 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, case. */ total = sizeof (notfound); - written = TEMP_FAILURE_RETRY (send (fd, ¬found, total, - MSG_NOSIGNAL)); + if (fd != -1) + written = TEMP_FAILURE_RETRY (send (fd, ¬found, total, + MSG_NOSIGNAL)); dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1); diff --git a/nscd/servicescache.c b/nscd/servicescache.c index 2dd1cc5675e..b0a29779350 100644 --- a/nscd/servicescache.c +++ b/nscd/servicescache.c @@ -104,8 +104,9 @@ cache_addserv (struct database_dyn *db, int fd, request_header *req, case. */ total = sizeof (notfound); - written = TEMP_FAILURE_RETRY (send (fd, ¬found, total, - MSG_NOSIGNAL)); + if (fd != -1) + written = TEMP_FAILURE_RETRY (send (fd, ¬found, total, + MSG_NOSIGNAL)); dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1);