diff options
author | Sebastian Benoit <benno@cvs.openbsd.org> | 2013-11-15 22:32:56 +0000 |
---|---|---|
committer | Sebastian Benoit <benno@cvs.openbsd.org> | 2013-11-15 22:32:56 +0000 |
commit | 72d598923790359ac674a2fd8d12ee91f4639345 (patch) | |
tree | 384c0daebdc6a16f31014148df62e91784bce815 /lib/libc | |
parent | d77db38a99c37922b14991741a09951af3b0c621 (diff) |
getpwnam_r() and getpwuid_r() reopen the passwd even when called with
setpassent(stayopen).
Bug found and fixed by Erik Lax <erik-AT-halon-DOT-se>
ok millert@ guenther@
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/getpwent.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 5292d9eef3a..a35419db325 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getpwent.c,v 1.47 2013/11/12 07:04:54 deraadt Exp $ */ +/* $OpenBSD: getpwent.c,v 1.48 2013/11/15 22:32:55 benno Exp $ */ /* * Copyright (c) 2008 Theo de Raadt * Copyright (c) 1988, 1993 @@ -708,10 +708,8 @@ getpwnam_r(const char *name, struct passwd *pw, char *buf, size_t buflen, { struct passwd *pwret = NULL; int flags = 0, *flagsp; - DB *savedb; _THREAD_PRIVATE_MUTEX_LOCK(pw); - savedb = _pw_db; if (!_pw_db && !__initdb()) goto fail; @@ -728,7 +726,7 @@ getpwnam_r(const char *name, struct passwd *pw, char *buf, size_t buflen, if (!pwret) pwret = _pwhashbyname(name, buf, buflen, pw, flagsp); - if (savedb != _pw_db || !_pw_stayopen) { + if (!_pw_stayopen) { (void)(_pw_db->close)(_pw_db); _pw_db = NULL; } @@ -755,10 +753,8 @@ getpwuid_r(uid_t uid, struct passwd *pw, char *buf, size_t buflen, { struct passwd *pwret = NULL; int flags = 0, *flagsp; - DB *savedb; _THREAD_PRIVATE_MUTEX_LOCK(pw); - savedb = _pw_db; if (!_pw_db && !__initdb()) goto fail; @@ -775,7 +771,7 @@ getpwuid_r(uid_t uid, struct passwd *pw, char *buf, size_t buflen, if (!pwret) pwret = _pwhashbyuid(uid, buf, buflen, pw, flagsp); - if (savedb != _pw_db || !_pw_stayopen) { + if (!_pw_stayopen) { (void)(_pw_db->close)(_pw_db); _pw_db = NULL; } |