From f7d60097d803e465a874911bad08447470443547 Mon Sep 17 00:00:00 2001 From: guenther Date: Sat, 23 Mar 2024 16:30:01 +0000 Subject: [PATCH] readdir_r(3) was never necessary and has been deprecated by POSIX. Document that in the manpage and stop using it internally. ok deraadt@ millert@ jmc@ --- lib/libc/gen/opendir.3 | 20 +++++++++++++++----- lib/libskey/skeylogin.c | 10 +++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/libc/gen/opendir.3 b/lib/libc/gen/opendir.3 index c5db9473f1c..397508f3197 100644 --- a/lib/libc/gen/opendir.3 +++ b/lib/libc/gen/opendir.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: opendir.3,v 1.2 2022/09/11 06:38:10 jmc Exp $ +.\" $OpenBSD: opendir.3,v 1.3 2024/03/23 16:30:01 guenther Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: September 11 2022 $ +.Dd $Mdocdate: March 23 2024 $ .Dt OPENDIR 3 .Os .Sh NAME @@ -112,9 +112,11 @@ operation. .Pp The .Fn readdir_r -function (much like -.Fn readdir ) -initializes the +function is a deprecated variant of +.Fn readdir . +Like +.Fn readdir , +it initializes the .Vt dirent structure referenced by .Fa entry @@ -304,3 +306,11 @@ The .Fn fdopendir function appeared in .Ox 5.0 . +.Sh CAVEATS +The +.Fn readdir_r +function was intended to provide a thread-safe version of +.Fn readdir . +However, it was later found to be both unnecessary in the typical +usage and unportable due to insufficient buffer sizing guidance. +It was therefore officially deprecated in issue 8. diff --git a/lib/libskey/skeylogin.c b/lib/libskey/skeylogin.c index 0b7352983c0..78f1d8b01e9 100644 --- a/lib/libskey/skeylogin.c +++ b/lib/libskey/skeylogin.c @@ -10,7 +10,7 @@ * * S/Key verification check, lookups, and authentication. * - * $OpenBSD: skeylogin.c,v 1.64 2023/03/15 17:01:35 millert Exp $ + * $OpenBSD: skeylogin.c,v 1.65 2024/03/23 16:30:01 guenther Exp $ */ #ifdef QUOTA @@ -207,7 +207,7 @@ skeylookup(struct skey *mp, char *name) int skeygetnext(struct skey *mp) { - struct dirent entry, *dp; + struct dirent *dp; int rval; if (mp->keyfile != NULL) { @@ -220,10 +220,10 @@ skeygetnext(struct skey *mp) return (-1); rval = 1; - while ((readdir_r(mp->keydir, &entry, &dp)) == 0 && dp == &entry) { + while ((dp = readdir(mp->keydir)) != NULL) { /* Skip dot files and zero-length files. */ - if (entry.d_name[0] != '.' && - (rval = skeygetent(-1, mp, entry.d_name)) != 1) + if (dp->d_name[0] != '.' && + (rval = skeygetent(-1, mp, dp->d_name)) != 1) break; } -- 2.20.1