diff mbox

[v2] expand: Fix glibc glob(3) support

Message ID 20180326095024.GA8580@gondor.apana.org.au (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Herbert Xu March 26, 2018, 9:50 a.m. UTC
On Mon, Mar 26, 2018 at 12:27:41AM +0800, Herbert Xu wrote:
>
> I tried making it work, and it looks like it should work with
> the latest glibc as they have just fixed a critical issue that
> would otherwise require nasty hacks to work around:
> 
> 	https://sourceware.org/bugzilla/show_bug.cgi?id=866
> 
> So I'll give it some time to filter through before trying it again.

OK, with this patch and glibc 2.27 it appears to be working:

---8<---
It's been a while since we disabled glob(3) support by default.
It appears to be working now, however, we have to change our
code to detect the no-match case correctly.

In particular, we need to test for GLOB_NOMAGIC | GLOB_NOCHECK
instead of GLOB_MAGCHAR.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
diff mbox

Patch

diff --git a/src/expand.c b/src/expand.c
index 705fef7..bc1f760 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -1188,7 +1188,8 @@  expandmeta(str, flag)
 			ckfree(p);
 		switch (i) {
 		case 0:
-			if (!(pglob.gl_flags & GLOB_MAGCHAR))
+			if ((pglob.gl_flags & (GLOB_NOMAGIC | GLOB_NOCHECK)) ==
+			    (GLOB_NOMAGIC | GLOB_NOCHECK))
 				goto nometa2;
 			addglob(&pglob);
 			globfree(&pglob);