CVSROOT:        /cvs
Module name:    src
Changes by:     schwa...@cvs.openbsd.org        2009/12/19 15:41:39

Modified files:
        lib/libc/gen   : getgrent.c 

Log message:
Implement proper error handling for getgrent(3), getgrnam(3) and getgrgid(3).

1) Distinguish normal end of data (like eof, YPERR_NOMORE, YPERR_KEY)
from error conditions.
2) Save errno(2) and restore it in case of success, as suggested by deraadt@
and b...@.

While this code is touched,
* move the common code for the yp_first and yp_next calls after the
respective if/else-block; note that free(data) is not needed in case of
failure and that __ypcurrent = NULL does no harm after failing yp_first.
* return 0, not NULL: the return value of grscan is int, not a pointer.

This is the last part of the work done on getgrent.c during c2k9,
heavily relying on the other improvements done at that time.
This has been rotting in my tree far too long.

"get it in" deraadt@; also lightly tested by simon@ some time ago

Reply via email to