diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-07-07 16:15:16 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-07-07 16:15:16 +0000 |
commit | 2479aa48ada4c3c8bad181dede001550dcbe1549 (patch) | |
tree | f7794c1c060dd89218317463b8629d45371fc5e1 /nscd | |
parent | 54854dd79228b33ffcc22d5646247c911b64d98c (diff) |
* nscd/nscd_helper.c (get_mapping): Handle short replies instead
of crashing. When this is the case or if the reply is malformed,
don't try to close the new file descriptor since it does not
exist.
Patch in part by Guillaume Chazarain <guichaz@yahoo.fr>.
Diffstat (limited to 'nscd')
-rw-r--r-- | nscd/nscd_helper.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index 1f56ccf6aa..79644a4da1 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -269,11 +269,12 @@ get_mapping (request_type type, const char *key, != keylen, 0)) goto out_close2; - mapfd = *(int *) CMSG_DATA (cmsg); + if (__builtin_expect (CMSG_FIRSTHDR (&msg) == NULL + || (CMSG_FIRSTHDR (&msg)->cmsg_len + != CMSG_LEN (sizeof (int))), 0)) + goto out_close2; - if (__builtin_expect (CMSG_FIRSTHDR (&msg)->cmsg_len - != CMSG_LEN (sizeof (int)), 0)) - goto out_close; + mapfd = *(int *) CMSG_DATA (cmsg); struct stat64 st; if (__builtin_expect (strcmp (resdata, key) != 0, 0) |