From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11378 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] glob: fix / matching Date: Wed, 31 May 2017 22:00:42 -0400 Message-ID: <20170601020042.GJ1627@brightrain.aerifal.cx> References: <20170528015918.GC1627@brightrain.aerifal.cx> <20170528025520.GF1627@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="NDin8bjvE/0mNLFQ" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1496282460 19072 195.159.176.226 (1 Jun 2017 02:01:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 1 Jun 2017 02:01:00 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11391-gllmg-musl=m.gmane.org@lists.openwall.com Thu Jun 01 04:00:54 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dGFPx-0004el-EK for gllmg-musl@m.gmane.org; Thu, 01 Jun 2017 04:00:53 +0200 Original-Received: (qmail 29797 invoked by uid 550); 1 Jun 2017 02:00:55 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 29776 invoked from network); 1 Jun 2017 02:00:54 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11378 Archived-At: --NDin8bjvE/0mNLFQ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sun, May 28, 2017 at 05:06:45PM +0200, Julien Ramseier wrote: > > > Le 28 mai 2017 à 04:55, Rich Felker a écrit : > >> > >> I'm confused how this patch differs from just removing the "if (*p)" > >> condition before calling match_in_dir. Does match_in_dir actually work > >> if p points to an empty string? I thought not... > > > > Hmm, just removing the "if (*p)" seems to make it work; it looks like > > match_in_dir covers this case fine. I'd like a second opinion on > > whether this looks okay since I haven't touched this code in years, > > but I suspect it'll turn out to be an okay fix for now... > > > > > The "if (*p)" is needed, otherwise match_in_dir will append an empty > match when p = "". Indeed. How about the attached? I did look at your patch, and although it's probably fine, it does have additional side effects like moving the length check across the slash-skipping. That's part of why I looked for a minimally invasive approach. Rich --NDin8bjvE/0mNLFQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="globroot.diff" diff --git a/src/regex/glob.c b/src/regex/glob.c index 5b6ff12..2d4d562 100644 --- a/src/regex/glob.c +++ b/src/regex/glob.c @@ -179,7 +179,7 @@ int glob(const char *restrict pat, int flags, int (*errfunc)(const char *path, i if (strnlen(p, PATH_MAX+1) > PATH_MAX) return GLOB_NOSPACE; - if (*p) error = match_in_dir(d, p, flags, errfunc, &tail); + if (*pat) error = match_in_dir(d, p, flags, errfunc, &tail); if (error == GLOB_NOSPACE) { freelist(&head); return error; --NDin8bjvE/0mNLFQ--