diff options
author | 2013-11-15 22:32:55 +0000 | |
---|---|---|
committer | 2013-11-15 22:32:55 +0000 | |
commit | 047d985d14f97293a028830bf18e862cf6ee673d (patch) | |
tree | 30a5bc50d66a4e67e13fbe726a06f7285f151b16 /lib | |
parent | Include unistd.h as it is the standard location for getopt(). (diff) | |
download | wireguard-openbsd-047d985d14f97293a028830bf18e862cf6ee673d.tar.xz wireguard-openbsd-047d985d14f97293a028830bf18e862cf6ee673d.zip |
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')
-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; } |