httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31858] - regular expression matching broken on amd64
Date Tue, 02 Nov 2004 08:16:25 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31858>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31858

regular expression matching broken on amd64





------- Additional Comments From sbeck@gossamer-threads.com  2004-11-02 08:16 -------
I've been looking into this issue tonight. Havn't uncovered much except it's not
an issue with the system's regex library. I created this simple test which is
pretty much what apache seems to be trying to do:

#include <stdio.h>
#include <sys/types.h>
#include <regex.h>

int main(int argc, char *argv[])
{
    int ret;
    regex_t *r;
    const char *regex="\\.(gif|jpg|mp3|css|js|png)$";
    int flags = REG_EXTENDED;

    r = malloc(sizeof(regex_t));
    if (regcomp(r, regex, flags)) {
        printf("Error compiling regex\n");
        return 1;
    }
    ret = regexec(r, "index.html", 0, NULL, 0);
    printf("match: %d\n", ret == 0);
    return 0;
}

This works as it should. I added some printf() debugging into
src/main/http_core.c looks like this:

  printf("compiled '%s' into %p at %d\n", cmd->path, r, __LINE__);

That's at line 1760 after it compiles the regex. I also added a printf() in
src/main/http_request.c:

  printf("regex match on %s [%p]\n", test_file, entry_core->r);

on line 704 before it does the ap_regexec() call and a couple of prints to see
if it matches or not.

All of this is with a download of apache_1.3.31 non-patched, I compiled it
myself with the only options being --prefix=/tmp/test_apache. I didn't change
the conf file except to remove the other match on .htaccess and set the port to
8080. Here is the output I get:

gossamer test_apache # ./bin/httpd -X
compiled '\.(gif|jpg|mp3|css|js|png)$' into 0x58ae98 at 1760
compiled '\.(gif|jpg|mp3|css|js|png)$' into 0x58dd18 at 1760

Then when I make a request for / on that server:

regex match on htdocs [0x58dd18]
no match!
regex match on index.html [0x58dd18]
match!
regex match on favicon.ico [0x58dd18]
match!

As you can see index.html is matching the precompiled regex that it shouldn't.
I'm going to continue to investigate this. If anyone has any suggestions I'd
love to hear them.

Cheers,

Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


Mime
View raw message