From 1bf372eabf1fc394f23278df4bd132df0fb0ae23 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Mon, 24 Dec 2007 16:34:23 +0000 Subject: [PATCH] Band-aid (and micro-optimization) that makes it less likely to run out of stack space with overly-complex path patterns. Probably masks the problem reported by Lee in #1856679. Hohoho. --- urlmatch.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/urlmatch.c b/urlmatch.c index 176fdd30..3e4e621e 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -1,4 +1,4 @@ -const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.19 2007/09/02 13:42:11 fabiankeil Exp $"; +const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.20 2007/09/02 15:31:20 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/urlmatch.c,v $ @@ -33,6 +33,10 @@ const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.19 2007/09/02 13:42:11 fabianke * * Revisions : * $Log: urlmatch.c,v $ + * Revision 1.20 2007/09/02 15:31:20 fabiankeil + * Move match_portlist() from filter.c to urlmatch.c. + * It's used for url matching, not for filtering. + * * Revision 1.19 2007/09/02 13:42:11 fabiankeil * - Allow port lists in url patterns. * - Ditch unused url_spec member pathlen. @@ -1019,9 +1023,10 @@ void free_url_spec(struct url_spec *url) int url_match(const struct url_spec *pattern, const struct http_request *url) { - int port_matches; - int domain_matches; - int path_matches; + /* XXX: these should probably be functions. */ +#define PORT_MATCHES ((NULL == pattern->port_list) || match_portlist(pattern->port_list, url->port)) +#define DOMAIN_MATCHES ((NULL == pattern->dbuffer) || (0 == domain_match(pattern, url))) +#define PATH_MATCHES ((NULL == pattern->path) || (0 == regexec(pattern->preg, url->path, 0, NULL, 0))) if (pattern->tag_regex != NULL) { @@ -1029,11 +1034,7 @@ int url_match(const struct url_spec *pattern, return 0; } - port_matches = (NULL == pattern->port_list) || match_portlist(pattern->port_list, url->port); - domain_matches = (NULL == pattern->dbuffer) || (0 == domain_match(pattern, url)); - path_matches = (NULL == pattern->path) || (0 == regexec(pattern->preg, url->path, 0, NULL, 0)); - - return (port_matches && domain_matches && path_matches); + return (PORT_MATCHES && DOMAIN_MATCHES && PATH_MATCHES); } -- 2.39.2