diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-09-27 16:45:29 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-09-27 16:45:29 -0400 |
commit | aef84ca7ec87ed21c2a2d5eecf3b4bbd6cbe3db9 (patch) | |
tree | 8fec45826a94354abe12e973f89086bda52cc1f4 /src/passwd/getgrent.c | |
parent | 60164570111873175111cf8a5b973375e492eee9 (diff) | |
download | musl-aef84ca7ec87ed21c2a2d5eecf3b4bbd6cbe3db9.tar.gz musl-aef84ca7ec87ed21c2a2d5eecf3b4bbd6cbe3db9.tar.bz2 musl-aef84ca7ec87ed21c2a2d5eecf3b4bbd6cbe3db9.tar.xz musl-aef84ca7ec87ed21c2a2d5eecf3b4bbd6cbe3db9.zip |
fix clobbering of errno in get(pw|gr)([ug]id|nam) by fclose
Diffstat (limited to 'src/passwd/getgrent.c')
-rw-r--r-- | src/passwd/getgrent.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/passwd/getgrent.c b/src/passwd/getgrent.c index e9d25eba..4cbe1ebf 100644 --- a/src/passwd/getgrent.c +++ b/src/passwd/getgrent.c @@ -23,17 +23,23 @@ struct group *getgrent() struct group *getgrgid(gid_t gid) { struct group *gr; + int errno_saved; setgrent(); while ((gr=getgrent()) && gr->gr_gid != gid); + errno_saved = errno; endgrent(); + errno = errno_saved; return gr; } struct group *getgrnam(const char *name) { struct group *gr; + int errno_saved; setgrent(); while ((gr=getgrent()) && strcmp(gr->gr_name, name)); + errno_saved = errno; endgrent(); + errno = errno_saved; return gr; } |