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

 
 

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

Submitter:  Eric Blake <ericb>
Submitted:  Mon 03 Jan 2011 08:56:19 PM UTC
   
 
Category:  find Severity:  3 - Normal
Item Group:  Wrong result Status:  Fixed
Privacy:  Public Assigned to:  jay
Originator Name:  Eric Blake Open/Closed:  Closed
Release:  4.5.9 Fixed Release:  4.5.11
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group administrator
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>
Group 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>
Group administrator
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>
Group 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>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-02-02 jay Open/ClosedOpen Closed
        Fixed ReleaseNone 4.5.11
    2013-02-02 jay Assigned toNone jay
    2011-05-14 jay StatusConfirmed Fixed

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code