From 72d598923790359ac674a2fd8d12ee91f4639345 Mon Sep 17 00:00:00 2001 From: Sebastian Benoit Date: Fri, 15 Nov 2013 22:32:56 +0000 Subject: getpwnam_r() and getpwuid_r() reopen the passwd even when called with setpassent(stayopen). Bug found and fixed by Erik Lax ok millert@ guenther@ --- lib/libc/gen/getpwent.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'lib/libc') 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; } -- cgit v1.2.3