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

Bug#296490: libc6: getgrnam segfault (using __nscd_getgrnam_r)



Florian Weimer wrote:
* Tom Parker:
Calling getgrnam() with a NULL argument, with group in
/etc/nsswitch.conf set to 'compat' can cause a segfault in
__nscd_getgrnam_r due to a lack of a check for a NULL string before
doing strlen().

Is there any standard that defines the behavior of getgrnam(NULL)?

The man page GETGRNAM(3) says:

RETURN VALUE
The getgrnam() and getgrgid() functions return a pointer to the group information structure, or NULL if the matching entry is not found or an error occurs. If an error occurs, errno is set appropriately. If one wants to check errno after the call, it should be set to zero before the call.

I've had a quick look at the POSIX (1003.1-2004) specs, and they say approximately the same thing (see http://www.opengroup.org/onlinepubs/000095399/functions/getgrnam.html). There isn't an exact thing for what to do in the case of getgrnam(NULL), but given that the "matching entry is not found" (because there can't be a NULL group), then I think that returning NULL is the correct behaviour.





Reply to: