diff options
author | Andreas Schwab <schwab@suse.de> | 2012-12-04 16:14:13 +0100 |
---|---|---|
committer | Andreas Schwab <schwab@suse.de> | 2013-01-10 09:59:58 +0100 |
commit | dd31ac7a8e0d4cc24eee6815f9101caa5aa64291 (patch) | |
tree | 084cc65c5b744f23cada0fae9bfd4c0c1cbb3ca3 /nscd/initgrcache.c | |
parent | 3167bfc62bb38e3057f7694566b5bb157236a5a8 (diff) | |
download | glibc-dd31ac7a8e0d4cc24eee6815f9101caa5aa64291.tar glibc-dd31ac7a8e0d4cc24eee6815f9101caa5aa64291.tar.gz glibc-dd31ac7a8e0d4cc24eee6815f9101caa5aa64291.tar.bz2 glibc-dd31ac7a8e0d4cc24eee6815f9101caa5aa64291.zip |
Properly check for short writes when sending the response in nscd
* nscd/grpcache.c (cache_addgr): Properly check for short write.
* nscd/initgrcache.c (addinitgroupsX): Likewise.
* nscd/pwdcache.c (cache_addpw): Likewise.
* nscd/servicescache.c (cache_addserv): Likewise. Don't write
more than recsize.
Diffstat (limited to 'nscd/initgrcache.c')
-rw-r--r-- | nscd/initgrcache.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c index 196407c870..94b279d559 100644 --- a/nscd/initgrcache.c +++ b/nscd/initgrcache.c @@ -171,10 +171,12 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req, nip = nip->next; } + bool all_written; ssize_t total; ssize_t written; time_t timeout; out: + all_written = true; timeout = MAX_TIMEOUT_VALUE; if (!any_success) { @@ -379,6 +381,9 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req, # endif #endif written = writeall (fd, &dataset->resp, dataset->head.recsize); + + if (written != dataset->head.recsize) + all_written = false; } @@ -405,7 +410,7 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req, free (groups); - if (__builtin_expect (written != total, 0) && debug_level > 0) + if (__builtin_expect (!all_written, 0) && debug_level > 0) { char buf[256]; dbg_log (_("short write in %s: %s"), __FUNCTION__, |