summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2024-03-23 16:30:02 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2024-03-23 16:30:02 +0000
commit22b742bc9f984c3363b5544be71604b45607c24f (patch)
tree7d8c86dab3a7adb33c3753548c1e0edc5e04401a
parent1084835213a8f58f581f7d9f6c26a2661035888d (diff)
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@
-rw-r--r--lib/libc/gen/opendir.320
-rw-r--r--lib/libskey/skeylogin.c10
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;
}