mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: ????????? <g548462@gmail.com>
Cc: musl@lists.openwall.com
Subject: Re: fnmatch bug?
Date: Wed, 6 Aug 2014 14:12:00 +0200	[thread overview]
Message-ID: <20140806121159.GH22308@port70.net> (raw)
In-Reply-To: <CA+yBz7PKkVwCS7RasM-KefnfdPjw81+1ueVMBFVaD9eqaSRvqQ@mail.gmail.com>

* ????????? <g548462@gmail.com> [2014-08-06 18:11:22 +0800]:
> I have do another experiment.
> 

i added the mailing list back to CC in case others have fnmatch
issues as well

> musl-libc:
>      i = fnmatch("\\","\\",0);  // it returns 0 -> i=0
>      i = fnmatch("\\","\\",FNM_NOESCAPE);  // it also returns 0 -> i=0
> 
> But I think this two lines of code should return different value because I
> set the FNM_NOESCAPE flag.

fnmatch behaviour is unclear when the pattern ends in \
this is a bug in posix 2008 we reported earlier:

http://austingroupbugs.net/view.php?id=806

in the next revision of posix the current behaviour will
be non-conforming (there is a test for this in libc-test)

with FNM_NOESCAPE \ is not special so '\\' matches '\\'

> I also do same experiment in glibc:
> glibc:
>      i = fnmatch("\\","\\",0);  // it returns 1 -> i=1
>      i = fnmatch("\\","\\",FNM_NOESCAPE);  // it  returns 0 -> i=0

yes this is allowed

> In another case:
> musl-libc:
>      i = fnmatch("[1\\]","[1]",0);  // it returns 1 -> i=1
> glibc:
>      i = fnmatch("[1\\]","[1]",0);  //it returns 0 -> i=0
> 
> Because I DON'T set FNM_NOESCAPE flag, so glibc will escape ']' with two '\'
> And the return value should be 0 (match '[1]')
> Is it right ?

glibc is wrong here, in a bracket expression \ is not special
in any way, "[1\\]" only matches a single '1' or '\\' character


           reply	other threads:[~2014-08-06 12:12 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <CA+yBz7PKkVwCS7RasM-KefnfdPjw81+1ueVMBFVaD9eqaSRvqQ@mail.gmail.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140806121159.GH22308@port70.net \
    --to=nsz@port70.net \
    --cc=g548462@gmail.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).