From c110e664af9449e8fac24f4ed6e973d98d4fd268 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 5 Jun 2009 15:41:46 +0200 Subject: nss_wrapper: fix segfault in nwrap_gr_copy_r() metze --- lib/nss_wrapper/nss_wrapper.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/nss_wrapper/nss_wrapper.c b/lib/nss_wrapper/nss_wrapper.c index 7b67e695d6..317c251a24 100644 --- a/lib/nss_wrapper/nss_wrapper.c +++ b/lib/nss_wrapper/nss_wrapper.c @@ -816,7 +816,7 @@ static int nwrap_gr_copy_r(const struct group *src, struct group *dst, { char *first; char **lastm; - char *last; + char *last = NULL; off_t ofsb; off_t ofsm; off_t ofs; @@ -825,9 +825,14 @@ static int nwrap_gr_copy_r(const struct group *src, struct group *dst, first = src->gr_name; lastm = src->gr_mem; - while (*lastm) lastm++; + while (*lastm) { + last = *lastm; + lastm++; + } - last = *lastm; + if (last == NULL) { + last = src->gr_passwd; + } while (*last) last++; ofsb = PTR_DIFF(last + 1, first); -- cgit