Eric Blake wrote: > Eric Blake <ebb9 <at> byu.net> writes: > >> Thanks for your report. Indeed, looking at mgetgroups.c, if getgroups >> fails, mgetgroups returns -1 without assigning through *groups (likewise >> if realloc_groupbug fails, but that sets errno to ENOMEM). I also wonder >> if mgetgroups should be taught to recognize ENOSYS itself, and guarantee a >> zero-length array rather than returning with -1 in that case. > > I spotted another problem - id was not handling ENOMEM failures consistently > (in other words, it didn't go through xalloc_die). > > How about this alternative patch, which makes gnulib aware of ENOSYS, and > changes coreutils to use the more robust interface? > > > From: Eric Blake <[email protected]> > Date: Fri, 4 Dec 2009 08:26:23 -0700 > Subject: [PATCH] mgetgroups: add xgetgroups, and avoid ENOSYS failures > > * lib/mgetgroups.h (xgetgroups): New prototype. > * lib/mgetgroups.c (xgetgroups): New wrapper. > (mgetgroups): Handle ENOSYS. > * modules/mgetgroups (Depends-on): Add realloc-posix. > Reported by Scott <scott.gnu.2009 AT scottrix.co.uk>. ... > > From: Eric Blake <[email protected]> > Date: Fri, 4 Dec 2009 08:06:55 -0700 > Subject: [PATCH] id: handle systems without getgroups support > > If getgroups failed with ENOSYS, mgetgroups would unnecessarily > fail, and that provoked id into freeing an uninitialized pointer. > Meanwhile, we were not using xalloc_die properly. Both issues > are better solved in gnulib, by introducing xgetgroups; this > patch uses the new interface. > > * gnulib: Update, for mgetgroups improvments. > * src/id.c (print_full_info): Adjust caller to die on allocation > failure, and no longer worry about ENOSYS. > * src/group-list.c (print_group_list): Likewise. > * src/setuidgid.c (main): Likewise.
Both look fine. Thanks!
