From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5754 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: fnmatch.h bug? Date: Wed, 6 Aug 2014 06:23:17 -0400 Message-ID: <20140806102317.GY1674@brightrain.aerifal.cx> References: <20140806062759.GG22308@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1407320624 25224 80.91.229.3 (6 Aug 2014 10:23:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 Aug 2014 10:23:44 +0000 (UTC) Cc: musl@lists.openwall.com To: =?utf-8?B?5p6X5Yag5YSS?= Original-X-From: musl-return-5759-gllmg-musl=m.gmane.org@lists.openwall.com Wed Aug 06 12:23:39 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 1XEyNX-00024l-SO for gllmg-musl@plane.gmane.org; Wed, 06 Aug 2014 12:23:31 +0200 Original-Received: (qmail 1481 invoked by uid 550); 6 Aug 2014 10:23:31 -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 1469 invoked from network); 6 Aug 2014 10:23:30 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:5754 Archived-At: On Wed, Aug 06, 2014 at 06:03:33PM +0800, 林冠儒 wrote: > 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. Per a strict reading of the current text of backslash is not special when it appears at the end of the pattern string. See Austin Group issue #806: http://austingroupbugs.net/view.php?id=806 However, the way this was resolved (treating the final backslash as unmatchable or as an error) does not match musl's current behavior, so musl should be changed here. > 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 ? As nsz said, my interpretation of the requirements is that backslash in a bracket expression is never special; it is an ordinary character. This has been discussed before and nobody was able to prevent convincing evidence to the contrary, but it's been a while since I looked into the issue and I don't have the references handy. > It would be very helpful if you email me back and tell me what's the problem > Sorry ,my english is so poor. No problem, you're communicating fine. Rich