There's a bit of a silly bug I noticed in the 'oldfind' code, reproducible
as follows:

$ mkdir test
$ touch test/..test
$ oldfind test
test

Note that the file "test/..test" was not listed.

The attached patch fixes this.
From 48db4d23539907c2be85be2ba016110aa993a5a3 Mon Sep 17 00:00:00 2001
From: Phil Miller <[email protected]>
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
---
 find/find.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/find/find.c b/find/find.c
index a8c6b4f..a5530ba 100644
--- a/find/find.c
+++ b/find/find.c
@@ -1441,7 +1441,9 @@ process_dir (char *pathname, char *name, int pathlen, const struct stat *statp,
 	      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;
 	    }
 
-- 
2.1.4

_______________________________________________
Findutils-patches mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/findutils-patches

Reply via email to