summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2013-11-05 09:36:06 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2013-11-05 09:36:06 +0000
commit91c1ee5caac56161f64d3142791b7d3aeea6d43e (patch)
tree2c94a0e5f7c793e835608b06e19f7b4d909b835c
parent85d284fc089646be2a180b6b65a891579045ff16 (diff)
Make sure seekdir(3) works even when dirp->dd_buf still contains some
pending entries: At the time of the lseek(2), also invalidate the buffer in order to force getdents(2) during the next readdir(3). Because this throws away buffered data that could still be used in some cases, this is not particularly efficient, but at least it works; i will suggest optimizations soon. Bug found when investigating perl-5.18.1/t/op/threads-dirh.t that was reported broken by Andrew Fresh <andrew at afresh1 dot com>. ok guenther@ deraadt@
-rw-r--r--lib/libc/gen/telldir.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/libc/gen/telldir.c b/lib/libc/gen/telldir.c
index af3513a78b4..4791fab008c 100644
--- a/lib/libc/gen/telldir.c
+++ b/lib/libc/gen/telldir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: telldir.c,v 1.15 2013/08/16 05:27:39 guenther Exp $ */
+/* $OpenBSD: telldir.c,v 1.16 2013/11/05 09:36:05 schwarze Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -67,5 +67,6 @@ telldir(DIR *dirp)
void
__seekdir(DIR *dirp, long loc)
{
+ dirp->dd_loc = 0;
dirp->dd_curpos = lseek(dirp->dd_fd, loc, SEEK_SET);
}