Bad regex matcher
Andreas Schwab
schwab@suse.de
Tue Oct 22 07:01:00 GMT 2002
The following program apparently runs into an infinite loop in the regex
matcher (from the grep testsuite):
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <regex.h>
#define PATTERN "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$"
int
main ()
{
static struct re_pattern_buffer regex;
const char *s;
re_set_syntax (RE_SYNTAX_POSIX_EGREP);
s = re_compile_pattern (PATTERN, strlen (PATTERN), ®ex);
if (s)
exit (1);
re_search (®ex, "civic", 5, 0, 5, 0);
exit (0);
}
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
More information about the Libc-alpha
mailing list