I've been adding test cases to the "find" test suite. In the course
of this I have discovered a bug in the implementation of the "find
-perm /NNN" test. This is a GNU extension which was introduced in
findutils version 4.2.21 to work around a potential POSIX
incompatibility relating to the use of "-perm +NNN".
The effect of the bug is that find treats the construct as if the
slash were missing - only exact permission matching occurs. There is
no entry on Savannah for this bug.
The bug is fixed by the attached patch and this change will be
included in the next release of findutils. Therefore a complete list
of findutils versions affected by this bug is
4.2.21
4.2.22
4.2.23
4.2.24
Apologies for any inconvenience occasioned by the bug.
Regards,
James.
Index: parser.c
===================================================================
RCS file: /cvsroot/findutils/findutils/find/parser.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- parser.c 27 Jul 2005 10:31:22 -0000 1.77
+++ parser.c 31 Jul 2005 21:12:43 -0000 1.78
@@ -1278,6 +1278,7 @@
{
mode_t perm_val;
int mode_start = 0;
+ boolean havekind = false;
enum permissions_type kind = PERM_EXACT;
struct mode_change *change = NULL;
struct predicate *our_pred;
@@ -1290,6 +1291,7 @@
case '-':
mode_start = 1;
kind = PERM_AT_LEAST;
+ havekind = true;
break;
case '+':
@@ -1312,11 +1314,13 @@
mode_start = 0;
kind = PERM_EXACT;
}
+ havekind = true;
break;
case '/': /* GNU extension */
mode_start = 1;
kind = PERM_ANY;
+ havekind = true;
break;
default:
@@ -1340,17 +1344,25 @@
our_pred = insert_primary (entry);
- switch (argv[*arg_ptr][0])
+ if (havekind)
{
- case '-':
- our_pred->args.perm.kind = PERM_AT_LEAST;
- break;
- case '+':
- our_pred->args.perm.kind = PERM_ANY;
- break;
- default:
- our_pred->args.perm.kind = PERM_EXACT;
- break;
+ our_pred->args.perm.kind = kind;
+ }
+ else
+ {
+
+ switch (argv[*arg_ptr][0])
+ {
+ case '-':
+ our_pred->args.perm.kind = PERM_AT_LEAST;
+ break;
+ case '+':
+ our_pred->args.perm.kind = PERM_ANY;
+ break;
+ default:
+ our_pred->args.perm.kind = PERM_EXACT;
+ break;
+ }
}
our_pred->args.perm.val = perm_val & MODE_ALL;
(*arg_ptr)++;
_______________________________________________
Bug-findutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-findutils