3
0
forked from pool/findutils
findutils/findutils-oldfind-fix-dotdot-skipping.patch

101 lines
3.6 KiB
Diff
Raw Normal View History

Upstream patch to fix a problem in oldfind(1) skipping files starting with "..".
http://lists.gnu.org/archive/html/findutils-patches/2014-12/msg00004.html
2 patches squashed together:
- the fix by Phil Miller in find/find.c,
- the test for it by Bernhard Voelker.
--------------------------------------------------------------------------------
From 286a2ff1d1bb71837c72d44c88da8ba3827906d4 Mon Sep 17 00:00:00 2001
From: Phil Miller <mille121@illinois.edu>
Date: Mon, 29 Dec 2014 16:27:49 -0600
Subject: [PATCH] oldfind: Don't skip names matching ..*
Prevent errors like the following:
$ mkdir test
$ touch test/..test
$ oldfind test
test
Note that the file "test/..test" was not listed.
* find/find.c (process_dir): When skipping a directory's self and
parent entries, don't also skip other entries that happen to begin
with "..".
Copyright-paperwork-exempt: yes
--------------------------------------------------------------------------------
From bebee334524bc7c23ebc2db27f97094989a7de5d Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail@bernhard-voelker.de>
Date: Tue, 30 Dec 2014 14:38:56 +0100
Subject: [PATCH] tests: add test for the previously fixed regression
* find/testsuite/find.posix/dotdotfiles.exp: Add test to verify
oldfind(1) does not skip directory entries starting with "..".
* find/testsuite/find.posix/dotdotfiles.xo: Add expected output
for the above test.
* find/testsuite/Makefile.am (EXTRA_DIST_XO, EXTRA_DIST_EXP):
Mention the above new test files.
---
find/find.c | 4 +++-
find/testsuite/Makefile.am | 2 ++
find/testsuite/find.posix/dotdotfiles.exp | 7 +++++++
find/testsuite/find.posix/dotdotfiles.xo | 2 ++
5 files changed, 16 insertions(+), 1 deletion(-)
Index: find/find.c
===================================================================
--- find/find.c.orig
+++ find/find.c
@@ -1441,7 +1441,9 @@ process_dir (char *pathname, char *name,
namep = dp->d_name;
/* Skip "", ".", and "..". "" is returned by at least one buggy
implementation: Solaris 2.4 readdir on NFS file systems. */
- if (!namep[0] || (namep[0] == '.' && (namep[1] == '.' || namep[1] == 0)))
+ if (!namep[0] ||
+ (namep[0] == '.' && (namep[1] == 0 ||
+ (namep[1] == '.' && namep[2] == 0))))
continue;
}
Index: find/testsuite/Makefile.am
===================================================================
--- find/testsuite/Makefile.am.orig
+++ find/testsuite/Makefile.am
@@ -73,6 +73,7 @@ find.gnu/quit.xo \
find.gnu/xtype.xo \
find.posix/and.xo \
find.posix/depth1.xo \
+find.posix/dotdotfiles.xo \
find.posix/exec-nogaps.xo \
find.posix/exec-one.xo \
find.posix/files-not-expressions1.xo \
@@ -189,6 +190,7 @@ find.gnu/xtype.exp \
find.posix/and.exp \
find.posix/bracket-depth.exp \
find.posix/depth1.exp \
+find.posix/dotdotfiles.exp \
find.posix/empty-parens.exp \
find.posix/exec-nogaps.exp \
find.posix/exec-one.exp \
Index: find/testsuite/find.posix/dotdotfiles.exp
===================================================================
--- /dev/null
+++ find/testsuite/find.posix/dotdotfiles.exp
@@ -0,0 +1,7 @@
+# Test entries starting with "..", e.g. "..tmp".
+# Commit v4.5.10-95-ga29e61b introduced a regression
+# which made oldfind(1) skip such entries.
+exec rm -rf tmp
+exec mkdir tmp tmp/..tmp
+find_start p {tmp}
+exec rm -rf tmp
Index: find/testsuite/find.posix/dotdotfiles.xo
===================================================================
--- /dev/null
+++ find/testsuite/find.posix/dotdotfiles.xo
@@ -0,0 +1,2 @@
+tmp
+tmp/..tmp