bugfindutils - Bugs: bug #32043, find -name [ doesn't obey posix

 
 

bug #32043: find -name [ doesn't obey posix

Submitted by:  Eric Blake <ericb>
Submitted on:  Mon 03 Jan 2011 08:56:19 PM UTC  
 
Category: findSeverity: 3 - Normal
Item Group: Wrong resultStatus: Fixed
Privacy: PublicAssigned to: James Youngman <jay>
Originator Name: Eric BlakeOpen/Closed: Closed
Release: 4.5.9Fixed Release: 4.5.11

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 14 May 2011 10:25:52 AM UTC, comment #4:

Synced the glibc fix into gnulib, added a test to gnulib, and updated findutils to use the current version of gnulib.

James Youngman <jay>
Project AdministratorIn charge of this item.
Wed 11 May 2011 02:11:09 PM UTC, comment #3:

Oops, the glibc fix has not yet been backported to gnulib, so other platforms still have the bug.

Eric Blake <ericb>
Project Administrator
Wed 11 May 2011 09:00:19 AM UTC, comment #2:

http://sourceware.org/bugzilla/show_bug.cgi?id=12378 indicates that glibc is now updated (presumably to fix this bug). The fix appears to be http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=794c3ad3a405697e2663b00f616e319383b9bb7d which also introduces a test for this case.

Did this glibc change get incorporated into gnulib yet? Is there a test for it too?

James Youngman <jay>
Project AdministratorIn charge of this item.
Sat 08 Jan 2011 10:29:57 PM UTC, comment #1:

The bug lies in glibc, and is copied to all other platforms by virtue of the fact that gnulib copies glibc's implementation and we rely on gnulib to provide the GNU extension of casefolding.

http://sourceware.org/bugzilla/show_bug.cgi?id=12378

Eric Blake <ericb>
Project Administrator
Mon 03 Jan 2011 08:56:19 PM UTC, original submission:

On a Solaris machine:

$ /bin/find /usr/local/bin/ -name [
/usr/local/bin/[
$ /bin/find /usr/local/bin/ -name '\['
/usr/local/bin/[
$ find /usr/local/bin/ -name [
$ find /usr/local/bin/ -name '\['
/usr/local/bin/[
$ find --version | head -n1
find (GNU findutils) 4.5.9

The third command demonstrates the bug in GNU find. Find can (and should continue to) locate [ when it was specified with quoting, but POSIX also clearly states that an unmatched [ should be treated as a literal file name, rather than rejected as an invalid glob, as follows:

Line 89090 states that find -name matches according to XBD 2.13 (but not 2.13.3, since it is a match and not a filename expansion). And XBD 2.13, line 73748 states:

[ If an open bracket introduces a bracket expression as in XBD Section 9.3.5 (on page 184), except that the <exclamation-mark> character (’!’) shall replace the <circumflex> character (’ˆ’) in its role in a non-matching list in the regular expression notation, it shall introduce a pattern bracket expression. A bracket expression starting with an unquoted <circumflex> character produces unspecified results. Otherwise, ’[’ shall match the character itself.

Since [ is not matched by ], it is not a bracket expression, therefore, it shall match [ itself without requiring escaping. It should not be necessary to write -name '\[', when -name [ should do the same thing.

This may represent an even more fundamental bug in glibc and/or gnulib's fnmatch() implementation, although I'd have to step through the find code to state that for sure.

Eric Blake <ericb>
Project Administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jay (Posted a comment)
  • -unavailable- added by ericb (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 02 Feb 2013 02:52:09 PM UTCjayOpen/ClosedOpen=>Closed
      Fixed ReleaseNone=>4.5.11
    Sat 02 Feb 2013 02:49:45 PM UTCjayAssigned toNone=>jay
    Sat 14 May 2011 10:25:52 AM UTCjayStatusConfirmed=>Fixed

    Back to the top


    Powered by Savane 3.1-cleanup