mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] glob: fix / matching
Date: Wed, 31 May 2017 22:00:42 -0400	[thread overview]
Message-ID: <20170601020042.GJ1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <CE23B1E4-CE43-43D9-B8B6-E3876267DE42@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 989 bytes --]

On Sun, May 28, 2017 at 05:06:45PM +0200, Julien Ramseier wrote:
> 
> > Le 28 mai 2017 à 04:55, Rich Felker <dalias@libc.org> 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

[-- Attachment #2: globroot.diff --]
[-- Type: text/plain, Size: 484 bytes --]

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;

  reply	other threads:[~2017-06-01  2:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-19 14:59 Julien Ramseier
2017-05-28  1:59 ` Rich Felker
2017-05-28  2:55   ` Rich Felker
2017-05-28 15:06     ` Julien Ramseier
2017-06-01  2:00       ` Rich Felker [this message]
2017-06-03 16:15         ` Julien Ramseier

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=20170601020042.GJ1627@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --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).