Solaris10 libc bug: regexec() hangs
Hello,
I have found a bug in Solaris10 libc. Compiling a regex containing combinations of +,*,?
characters, and executing it on a certain string leads to a hang of regexec().
The regexec is finite in length, and is compiled successfully, the string I want to match with is finite in length, so regexec() shouldn't hang, but finish execution within a reasonable amount of time.
I tested the same regular expression/string combination on other platforms with GNU libc, and only Solaris's implementation hangs.
I am not sure what the appropriate place is for a bugreport on Solaris10, so I contacted this forum.
A test case to reproduce this can be found below:
I tested the hang on SunOS solaris10 5.10 Generic_118855-33 i86pc i386 i86pc,
compiler: gcc 3.4.6
Others have tested on Solaris 9, sparc, cc (not gcc) with similar results.
#include <stdio.h>
#include <regex.h>
int main(int argc,char* argv[])
{
regex_t preg;
const char * regex="^(/((([-$_@.&a-zA-Z0-9!*\"'(),]|%[0-9a-fA-f]{2}))+/?)*)?$";
int rc;
const char* text="/wwwwww.wwwww/wwwwww-www/wwww-www/www/www=wwww/wwwww.wwwww/wwww&ww=98 563257ahyrtmpzikqs&wwwww=wwwww/wwwww&wwww/wwww";
rc = regcomp(&preg,regex,REG_EXTENDED|REG_ICASE|REG_NOSUB);
if(rc) {
size_t buflen =regerror(rc,&preg,NULL,0);
char *errbuf = malloc(buflen);
if(errbuf) {
regerror(rc,&preg,errbuf,buflen);
fprintf(stderr,"Error in compiling regex:%s\n",errbuf);
free(errbuf);
} else
fprintf(stderr,"Error in compiling regex. Additionally an Out-of-memory error was encountered while generating a detailed error message\n");
return 1;
}
printf("regexec()\n");
regexec(&preg, text, 0, NULL, 0);
return 0;
}

