summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2013-10-06 17:57:12 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2013-10-06 17:57:12 +0000
commit5d53b4e16cf42ba5c7710e83f29307631838802c (patch)
tree1e5690be0918cb5e65272200b953bc6dc2e6be08 /lib/libc
parentbce251279f10514cf1472dd1903fc9bb8da2794d (diff)
fdopendir() needs to set dd_curpos so that an immediate telldir() works.
pointed out by and ok matthew@
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/opendir.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c
index eb139effaae..86038754999 100644
--- a/lib/libc/gen/opendir.c
+++ b/lib/libc/gen/opendir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: opendir.c,v 1.24 2013/08/13 05:52:12 guenther Exp $ */
+/* $OpenBSD: opendir.c,v 1.25 2013/10/06 17:57:11 guenther Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -75,6 +75,9 @@ fdopendir(int fd)
}
dirp = __fdopendir(fd);
if (dirp != NULL) {
+ /* Record current offset for immediate telldir() */
+ dirp->dd_curpos = lseek(fd, 0, SEEK_CUR);
+
/*
* POSIX doesn't require fdopendir() to set
* FD_CLOEXEC, so it's okay for this to fail.