Hi Bruno,
Bruno Haible <[email protected]> writes:
>> On Android compiling a testdir in termux results in test-glob failing
>> with the following:
>>
>> $ ./gltests/test-glob
>> test-glob.c:118: assertion 'res == 0' failed
>> Aborted ./gltests/test-glob
>>
>> I think this is because the shell is at /system/bin/sh instead of
>> /bin/sh.
>
> Yes, this comes from the absence of /bin/sh (cf. m4/sh-filename.m4).
I did not know that m4 file existed. Good to know.
>> How about accepting GLOB_NOMATCH in this case? Since the main purpose of
>> this test is to catch the glibc stack overflow.
>
> This patch has three problems:
> 1) It weakens the test also on glibc systems.
> 2) No, the purpose of the test is also to catch wrong exit codes without
> stack overflow, like on Cygwin.
> 3) m4/glob.m4 needs to adapted as well.
>
> Even after excluding that part of the test from m4/glob.m4, it fails.
> Namely, for n >= 4097, this test fails:
> ===============================================================================
> #include <stddef.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <glob.h>
> int
> main (void)
> {
> /* Test that glob with many trailing slashes or slashes following
> a wildcard does not overflow the stack as it did in glibc 2.42
> and earlier. */
> int n = 4097;
> char *p = malloc (n);
> glob_t g;
> int result = 0;
> if (p != NULL)
> {
> /* This test fails on glibc <= 2.42 (stack overflow). */
> memset (p, '/', n-1);
> p[n-1] = '\0';
> int ret = glob (p, 0, NULL, &g);
> printf ("ret = %d\n", ret);
> if (ret != 0)
> result |= 1;
> globfree (&g);
> }
> return result;
> }
> ===============================================================================
>
> Therefore I'm applying this patch:
Glad that I asked before pushing. Thanks!
Collin