fix glob failure to match plain "/" to root directory
authorRich Felker <dalias@aerifal.cx>
Thu, 8 Jun 2017 23:50:23 +0000 (19:50 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 8 Jun 2017 23:50:23 +0000 (19:50 -0400)
the check to prevent matching empty string wrongly blocked matching
of "/" due to checking emptiness after stripping leading slashes
rather than checking the full original argument string.

simplified from patch by Julien Ramseier.

src/regex/glob.c

index 5b6ff12..2d4d562 100644 (file)
@@ -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;