mirror of git://git.musl-libc.org/musl
fix clobbering of errno in get(pw|gr)([ug]id|nam) by fclose
This commit is contained in:
parent
6016457011
commit
aef84ca7ec
|
@ -23,17 +23,23 @@ struct group *getgrent()
|
||||||
struct group *getgrgid(gid_t gid)
|
struct group *getgrgid(gid_t gid)
|
||||||
{
|
{
|
||||||
struct group *gr;
|
struct group *gr;
|
||||||
|
int errno_saved;
|
||||||
setgrent();
|
setgrent();
|
||||||
while ((gr=getgrent()) && gr->gr_gid != gid);
|
while ((gr=getgrent()) && gr->gr_gid != gid);
|
||||||
|
errno_saved = errno;
|
||||||
endgrent();
|
endgrent();
|
||||||
|
errno = errno_saved;
|
||||||
return gr;
|
return gr;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct group *getgrnam(const char *name)
|
struct group *getgrnam(const char *name)
|
||||||
{
|
{
|
||||||
struct group *gr;
|
struct group *gr;
|
||||||
|
int errno_saved;
|
||||||
setgrent();
|
setgrent();
|
||||||
while ((gr=getgrent()) && strcmp(gr->gr_name, name));
|
while ((gr=getgrent()) && strcmp(gr->gr_name, name));
|
||||||
|
errno_saved = errno;
|
||||||
endgrent();
|
endgrent();
|
||||||
|
errno = errno_saved;
|
||||||
return gr;
|
return gr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,17 +23,23 @@ struct passwd *getpwent()
|
||||||
struct passwd *getpwuid(uid_t uid)
|
struct passwd *getpwuid(uid_t uid)
|
||||||
{
|
{
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
int errno_saved;
|
||||||
setpwent();
|
setpwent();
|
||||||
while ((pw=getpwent()) && pw->pw_uid != uid);
|
while ((pw=getpwent()) && pw->pw_uid != uid);
|
||||||
|
errno_saved = errno;
|
||||||
endpwent();
|
endpwent();
|
||||||
|
errno = errno_saved;
|
||||||
return pw;
|
return pw;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct passwd *getpwnam(const char *name)
|
struct passwd *getpwnam(const char *name)
|
||||||
{
|
{
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
int errno_saved;
|
||||||
setpwent();
|
setpwent();
|
||||||
while ((pw=getpwent()) && strcmp(pw->pw_name, name));
|
while ((pw=getpwent()) && strcmp(pw->pw_name, name));
|
||||||
|
errno_saved = errno;
|
||||||
endpwent();
|
endpwent();
|
||||||
|
errno = errno_saved;
|
||||||
return pw;
|
return pw;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue