From 2479aa48ada4c3c8bad181dede001550dcbe1549 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 7 Jul 2007 16:15:16 +0000 Subject: [PATCH] * 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 . --- ChangeLog | 8 ++++++++ nscd/nscd_helper.c | 9 +++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c62a99c50..6b20f8fd57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-05-29 Ulrich Drepper + + * 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 . + 2007-05-21 Ulrich Drepper * sysdeps/x86_64/cacheinfo.c (init_cacheinfo): Pass correct value 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) -- 2.11.4.GIT