From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5753 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?5p6X5Yag5YSS?= Newsgroups: gmane.linux.lib.musl.general Subject: Re: fnmatch.h bug? Date: Wed, 6 Aug 2014 18:03:33 +0800 Message-ID: References: <20140806062759.GG22308@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c2696aba073b04fff3158e X-Trace: ger.gmane.org 1407320022 16770 80.91.229.3 (6 Aug 2014 10:13:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 Aug 2014 10:13:42 +0000 (UTC) To: "?????????" , musl@lists.openwall.com Original-X-From: musl-return-5758-gllmg-musl=m.gmane.org@lists.openwall.com Wed Aug 06 12:13:36 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XEyDs-0007gN-H1 for gllmg-musl@plane.gmane.org; Wed, 06 Aug 2014 12:13:32 +0200 Original-Received: (qmail 22471 invoked by uid 550); 6 Aug 2014 10:13:30 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 15484 invoked from network); 6 Aug 2014 10:03:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=fu6zNX+8+rGMWlzVzWbsHRQD7ssGhljzmoFA2RO9SoA=; b=fn0BCddpNgeNjege5DFqc4bxeaF+k/C/hD+JLRd7ftRJUr/ykpIFaHIErEYP93EhzM WuQQMJp0RElFTxG2HzyjjO/0ipuX6UNJ1B1VIlaxPooMkbckxEJCme8Wiewm1dPnQ2St UKKxnh4V7rejrXpdOVdbg/vhMO+n1IOO+MHzAm3WBejeKDgmqICL95r7KpHB2RjU4mPb /FZyG1H+eRp6NK0TyZ4KrP+bQDLDk/4/b87k6XMiMEptni+EtIkHpybZXVKDH0QKYPPQ jdizqMFAIUf/bqHdK7ekJopklOWrLv/ybwRpKirCGDl/8pzX9xjB9QT8BF26tqBGCnY4 YMbA== X-Received: by 10.112.169.35 with SMTP id ab3mr996851lbc.41.1407319413489; Wed, 06 Aug 2014 03:03:33 -0700 (PDT) In-Reply-To: <20140806062759.GG22308@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:5753 Archived-At: --001a11c2696aba073b04fff3158e Content-Type: text/plain; charset=UTF-8 I have do another experiment. 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. 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 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 ? It would be very helpful if you email me back and tell me what's the problem Sorry ,my english is so poor. 2014-08-06 14:28 GMT+08:00 Szabolcs Nagy : > * ????????? [2014-08-06 11:01:40 +0800]: > > > > musl-libc: > > i = fnmatch( "[[?*\\]" , "\\" , 0 ); // it will return 0 -> i = 0 > > glibc: > > i = fnmatch( "[[?*\\]" , "\\" , 0 ); // it will return 1 -> i = 1 > > > > The return value is DIFFERENT ! > > I am confuse which library is wrong? > > If you have any idea, please response me and send an e-mail to me, > > in a bracket expression a backslash loses its special meaning > so this pattern matches a single '[', '?', '*' or '\\' character > > if glibc fails to match '\\' then it's a bug in their implementation > > (this exact pattern is even part of the libc-test suite for fnmatch) > --001a11c2696aba073b04fff3158e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I have do another experiment.

musl-libc:
= =C2=A0=C2=A0=C2=A0=C2=A0 i =3D fnmatch("\\","\\",0);=C2= =A0 // it returns 0 -> i=3D0
=C2=A0=C2=A0=C2=A0=C2=A0 i =3D fnmatch(&= quot;\\","\\",FNM_NOESCAPE);=C2=A0 // it also returns 0 ->= ; i=3D0

But I think this two lines of code should return different v= alue because I set the FNM_NOESCAPE flag.

I also do same experiment in glibc:
glibc: =C2=A0=C2=A0=C2=A0=C2=A0 i =3D fnmatch("\\","\\",0);=C2= =A0 // it returns 1 -> i=3D1=C2=A0=C2=A0=C2=A0=C2=A0 i =3D fnmatch("\\","\\",FNM_= NOESCAPE);=C2=A0 // it=C2=A0 returns 0 -> i=3D0


In another case:
musl-libc:
=C2=A0=C2= =A0=C2=A0=C2=A0 i =3D fnmatch("[1\\]","[1]",0);=C2=A0 /= / it returns 1 -> i=3D1
glibc:
=C2=A0=C2=A0=C2=A0=C2=A0 i = =3D fnmatch("[1\\]","[1]",0);=C2=A0 //it returns 0 ->= ; i=3D0

Because I DON'T set FNM_NOESCAPE flag, so glibc will esc= ape ']' with two '\'
And the return value sho= uld be 0 (match '[1]')
Is it right ?

It would be very helpful i= f you email me back and tell me what's the problem
S= orry ,my english is so poor.



2014-08-= 06 14:28 GMT+08:00 Szabolcs Nagy <nsz@port70.net>:
* ????????? <g548462@gmail.com&= gt; [2014-08-06 11:01:40 +0800]:
>
> musl-libc:
> =C2=A0 =C2=A0 =C2=A0i =3D fnmatch( "[[?*\\]" , "\\"= ; , 0 ); // it will return 0 -> i =3D 0
> glibc:
> =C2=A0 =C2=A0 =C2=A0i =3D fnmatch( "[[?*\\]" , "\\"= ; , 0 ); // it will return 1 -> i =3D 1
>
> The return value is DIFFERENT !
> I am confuse which library is wrong?
> If you have any idea, please response me and send an e-mail to me,

in a bracket expression a backslash loses its special meaning
so this pattern matches a single '[', '?', '*' or &= #39;\\' character

if glibc fails to match '\\' then it's a bug in their implement= ation

(this exact pattern is even part of the libc-test suite for fnmatch)

--001a11c2696aba073b04fff3158e--