summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-08-03 22:23:49 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-08-03 22:23:49 +0000
commita2df23a819e7a79f591df09afccdea34230ae09f (patch)
tree325932ff07e4fe58b10e304f3b6f5a47ed42f00d /lib
parent48862fffe594b4e8de5552dfb2afc2b57894fc84 (diff)
Update sp->fts_cur in fts_read() before returning NULL. This
prevents a duplicate free() in fts_close(). From karls@inet.no with some other, similar cases added.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/fts.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c
index b4973f2e93d..741d07cacca 100644
--- a/lib/libc/gen/fts.c
+++ b/lib/libc/gen/fts.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fts.c,v 1.27 2001/05/31 23:30:48 millert Exp $ */
+/* $OpenBSD: fts.c,v 1.28 2001/08/03 22:23:48 millert Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
#else
-static char rcsid[] = "$OpenBSD: fts.c,v 1.27 2001/05/31 23:30:48 millert Exp $";
+static char rcsid[] = "$OpenBSD: fts.c,v 1.28 2001/08/03 22:23:48 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -431,6 +431,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
if (p->fts_level == FTS_ROOTLEVEL) {
if (FCHDIR(sp, sp->fts_rfd)) {
SET(FTS_STOP);
+ sp->fts_cur = p;
return (NULL);
}
} else if (p->fts_flags & FTS_SYMFOLLOW) {
@@ -439,12 +440,14 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
(void)close(p->fts_symfd);
errno = saved_errno;
SET(FTS_STOP);
+ sp->fts_cur = p;
return (NULL);
}
(void)close(p->fts_symfd);
} else if (!(p->fts_flags & FTS_DONTCHDIR) &&
fts_safe_changedir(sp, p->fts_parent, -1, "..")) {
SET(FTS_STOP);
+ sp->fts_cur = p;
return (NULL);
}
p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP;