bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnulib/glibc bug in fnmatch()


From: Eric Blake
Subject: gnulib/glibc bug in fnmatch()
Date: Sat, 08 Jan 2011 15:34:36 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

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

which is in turn the root cause of this findutils bug:
https://savannah.gnu.org/bugs/index.php?32043

Basically, fnmatch("[","[",0) is required by POSIX 2008 to return 0, but
in glibc, it returns FNM_NOMATCH.

(It's behavior was more or less undefined in POSIX 2001, because it
represented an unterminated bracket expression which is thus an invalid
glob; but POSIX 2008 tightened the definition of globs to require that a
leading bracket that does not introduce a bracket expression must match
itself, in light of the fact that the [ utility (aka test) is an example
of a file name that looks like an unterminated bracket expression but
does not trigger globbing.)

I'm not sure how simple the fix will be, or how fast it will be patched
in glibc, but since gnulib copies the glibc definition, we'll need to
fix the gnulib implementation of fnmatch.

If it proves too hard to actually patch the glibc implementation, a
possible gnulib solution is to provide a wrapper that scans the pattern
argument for unterminated [ expressions, and replaces them with \[ (but
I hope that we can come up with a real fix in the fnmatch code itself).

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]