From cf3b23ffcd95841f1d36a3c808c415b41d70b3a9 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 29 Jun 2011 23:33:38 -0400 Subject: 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. --- nscd/grpcache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'nscd/grpcache.c') diff --git a/nscd/grpcache.c b/nscd/grpcache.c index fa21929..0e7f81f 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); -- cgit v1.1