nss_wrapper: fix segfault in nwrap_gr_copy_r()
authorStefan Metzmacher <metze@samba.org>
Fri, 5 Jun 2009 13:41:46 +0000 (15:41 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 5 Jun 2009 13:52:20 +0000 (15:52 +0200)
metze

lib/nss_wrapper/nss_wrapper.c

index 7b67e695d65a6dcef6a4946152d07878508fda0a..317c251a24b296044e91fe6fb84ded800fa1e21a 100644 (file)
@@ -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);