This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Bad regex matcher
- From: Andreas Schwab <schwab at suse dot de>
- To: Isamu Hasegawa <isamu at yamato dot ibm dot com>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Tue, 22 Oct 2002 16:00:55 +0200
- Subject: Bad regex matcher
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."