about summary refs log tree commit diff
path: root/nscd/servicescache.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-06-29 23:33:38 -0400
committerUlrich Drepper <drepper@gmail.com>2011-06-29 23:33:38 -0400
commitcf3b23ffcd95841f1d36a3c808c415b41d70b3a9 (patch)
treefa9fe9952e8ff971be44741bfafb4b11e6477732 /nscd/servicescache.c
parent5c0b8d9013560bb24805844d31a7fb3959ee1e8d (diff)
downloadglibc-cf3b23ffcd95841f1d36a3c808c415b41d70b3a9.tar.gz
glibc-cf3b23ffcd95841f1d36a3c808c415b41d70b3a9.tar.xz
glibc-cf3b23ffcd95841f1d36a3c808c415b41d70b3a9.zip
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.
Diffstat (limited to 'nscd/servicescache.c')
-rw-r--r--nscd/servicescache.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/nscd/servicescache.c b/nscd/servicescache.c
index 2dd1cc5675..b0a2977935 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, &notfound, total,
-					      MSG_NOSIGNAL));
+	  if (fd != -1)
+	    written = TEMP_FAILURE_RETRY (send (fd, &notfound, total,
+						MSG_NOSIGNAL));
 
 	  dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
 				   1);