diff options
author | Jim Meyering <meyering@fb.com> | 2018-12-15 15:24:21 -0800 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2018-12-15 15:28:10 -0800 |
commit | 55a4abd92a0a8fa0a9d9aff3892505f7b0c6d73c (patch) | |
tree | 7d29b8ee9b601445e886ec0c7a248a5447b2396e /tests/test-regex.c | |
parent | a31e63fd605e0f91a0f02b68bd05f57c5422fb56 (diff) | |
download | gnulib-55a4abd92a0a8fa0a9d9aff3892505f7b0c6d73c.tar.gz |
regex: work around a bug in glibc-2.27 and prior
* m4/regex.m4 (gl_REGEX): Reject any system regexp that gets a failed
assertion for /0|()0|\1|0/.
* tests/test-regex.c (main): Add the same test here.
Diffstat (limited to 'tests/test-regex.c')
-rw-r--r-- | tests/test-regex.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test-regex.c b/tests/test-regex.c index 0a009b896c..a0aa1123be 100644 --- a/tests/test-regex.c +++ b/tests/test-regex.c @@ -237,6 +237,17 @@ main (void) if (! REG_STARTEND) result |= 64; + /* Matching with the compiled form of this regexp would provoke + an assertion failure prior to glibc-2.28: + regexec.c:1375: pop_fail_stack: Assertion 'num >= 0' failed + With glibc-2.28, compilation fails and reports the invalid + back reference. */ + re_set_syntax (RE_SYNTAX_POSIX_EGREP); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("0|()0|\\1|0", 10, ®ex); + if (!s || strcmp (s, "Invalid back reference")) + result |= 64; + #if 0 /* It would be nice to reject hosts whose regoff_t values are too narrow (including glibc on hosts with 64-bit ptrdiff_t and |