tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

2k NIS groups enrty causes memfault.



I'm only seeing this on netbsd-5-1-RELEASE/amd64
a netbsd-5-1-RC4/i386 box on the same net has no problem.

While running id(1), getgrgid() ends up dying in _gr_copy:

        for (memc = 0; fromgrp->gr_mem[memc]; memc++)
                continue;

because fromgrp->gr_mem is NULL.

This happens because when _gr_parse() is called from __grscan_nis()
via _nis_getgrgid_r(), it returns 0 because the groups members won't fit
in the buffer, but __grscan_nis() does not alter rv from NS_SUCCESS.
So when __grscan_compat() calls _gr_copy() we need to check for this.

Index: lib/libc/gen/getgrent.c
===================================================================
RCS file: /cvsroot/src/lib/libc/gen/getgrent.c,v
retrieving revision 1.62
diff -u -p -r1.62 getgrent.c
--- lib/libc/gen/getgrent.c     28 Apr 2008 20:22:59 -0000      1.62
+++ lib/libc/gen/getgrent.c     9 Jun 2011 01:25:29 -0000
@@ -270,6 +270,9 @@ _gr_copy(struct group *fromgrp, struct g
        COPYSTR(grp->gr_passwd, fromgrp->gr_passwd);
        grp->gr_gid = fromgrp->gr_gid;
 
+       if (fromgrp->gr_mem == NULL)
+               return 0;
+
        for (memc = 0; fromgrp->gr_mem[memc]; memc++)
                continue;
        memc++;                                 /* for final NULL */


Home | Main Index | Thread Index | Old Index