]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Avoid the double-free (first in fts_read, second in fts_close) that
authorJim Meyering <jim@meyering.net>
Tue, 10 Jan 2006 11:55:13 +0000 (11:55 +0000)
committerJim Meyering <jim@meyering.net>
Tue, 10 Jan 2006 11:55:13 +0000 (11:55 +0000)
would occur when an `active' directory is made inaccessible (e.g.,
via chmod a-x) during a traversal.

(fts_read): After a failed fchdir, update sp->fts_cur
before returning.  Reproduce this failure by
mkdir -p a/b; cd a; chmod a-x . b
Reported by Stavros Passas.

lib/fts.c

index ed09697e050ae0830b17bbef2bc953a4e431c4cf..fb1a72a00254724bb152f0a398db064621d595c7 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -522,6 +522,7 @@ next:       tmp = p;
                if (p->fts_level == FTS_ROOTLEVEL) {
                        if (FCHDIR(sp, sp->fts_rfd)) {
                                SET(FTS_STOP);
+                               sp->fts_cur = p;
                                return (NULL);
                        }
                        fts_load(sp, p);