From: André Malo Date: Wed, 2 Jun 2004 22:40:23 +0000 (+0000) Subject: Fix a bunch of cases where the return code of the regex compiler X-Git-Tag: 2.0.50~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df1f03456ffa4bd917d34e6beab43e0b526cc77b;p=thirdparty%2Fapache%2Fhttpd.git Fix a bunch of cases where the return code of the regex compiler was not checked properly. This affects: mod_setenvif, mod_usertrack, mod_proxy, mod_proxy_ftp and core. PR: 28218 Reviewed by: Jeff Trawick, Joe Orton git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@103823 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 255de92ac4b..48736920509 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,9 @@ Changes with Apache 2.0.50 + *) Fix a bunch of cases where the return code of the regex compiler + was not checked properly. This affects: mod_setenvif, mod_usertrack, + mod_proxy, mod_proxy_ftp and core. PR 28218. [André Malo] + *) mod_ssl: Fix a potential segfault in the 'shmcb' session cache for small cache sizes. PR 27751. [Geoff Thorpe ] diff --git a/STATUS b/STATUS index 6098b84bdfb..db978407820 100644 --- a/STATUS +++ b/STATUS @@ -1,5 +1,5 @@ APACHE 2.0 STATUS: -*-text-*- -Last modified at [$Date: 2004/06/02 14:30:40 $] +Last modified at [$Date: 2004/06/02 22:40:21 $] Release: @@ -179,17 +179,6 @@ PATCHES TO BACKPORT FROM 2.1 modules/loggers/mod_log_config.c: r1.116 +1: nd - *) Fix a bunch of cases where the return code of the regex compiler - was not checked properly. The 1.3-diff is here: - http://www.apache.org/~nd/regex-return-1.3.diff (only core and - mod_usertrack affected). PR 28218. - modules/metadata/mod_setenvif.c: r1.51 - modules/metadata/mod_usertrack.c: r1.52 - modules/proxy/mod_proxy.c: r1.99 - modules/proxy/proxy_ftp.c: r1.140 - server/core.c: r1.272 - +1: nd, trawick, jorton - *) mod_usertrack: Escape the cookie_name before pasting into the regexp. (2.0 + 1.3) modules/metadata/mod_usertrack.c: r1.51 diff --git a/modules/metadata/mod_setenvif.c b/modules/metadata/mod_setenvif.c index 7ac6a6f08bb..7608871d1b4 100644 --- a/modules/metadata/mod_setenvif.c +++ b/modules/metadata/mod_setenvif.c @@ -174,11 +174,12 @@ static int is_header_regex(apr_pool_t *p, const char* name) */ regex_t *preg = ap_pregcomp(p, "^[-A-Za-z0-9_]*$", (REG_EXTENDED | REG_NOSUB )); - if (preg) { - if (ap_regexec(preg, name, 0, NULL, 0)) { - return 1; - } + ap_assert(preg != NULL); + + if (ap_regexec(preg, name, 0, NULL, 0)) { + return 1; } + return 0; } diff --git a/modules/metadata/mod_usertrack.c b/modules/metadata/mod_usertrack.c index 6a345a76f47..805d51e8f50 100644 --- a/modules/metadata/mod_usertrack.c +++ b/modules/metadata/mod_usertrack.c @@ -168,6 +168,7 @@ static void set_and_comp_regexp(cookie_dir_rec *dcfg, dcfg->regexp_string = apr_pstrcat(p, "^", cookie_name, "=([^;]+)|;[ \t]+", cookie_name, "=([^;]+)", NULL); dcfg->regexp = ap_pregcomp(p, dcfg->regexp_string, REG_EXTENDED); + ap_assert(dcfg->regexp != NULL); } static int spot_cookie(request_rec *r) diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 78a0e12ce45..069c97c3465 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -945,6 +945,9 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg) */ if (thiscmd->cmd_data) { /* */ r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED); + if (!r) { + return "Regex could not be compiled"; + } } else if (!strcmp(cmd->path, "~")) { cmd->path = ap_getword_conf(cmd->pool, &arg); @@ -953,6 +956,9 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg) if (strncasecmp(cmd->path, "proxy:", 6)) cmd->path += 6; r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED); + if (!r) { + return "Regex could not be compiled"; + } } /* initialize our config and fetch it */ diff --git a/modules/proxy/proxy_ftp.c b/modules/proxy/proxy_ftp.c index 11c65c138ff..fdd9172566f 100644 --- a/modules/proxy/proxy_ftp.c +++ b/modules/proxy/proxy_ftp.c @@ -430,6 +430,7 @@ apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *in) /* Compile the output format of "ls -s1" as a fallback for non-unix ftp listings */ re = ap_pregcomp(p, LS_REG_PATTERN, REG_EXTENDED); + ap_assert(re != NULL); /* get a complete line */ /* if the buffer overruns - throw data away */ diff --git a/server/core.c b/server/core.c index 7d747098b21..409e7b188f3 100644 --- a/server/core.c +++ b/server/core.c @@ -1623,9 +1623,15 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg) if (!cmd->path) return " block must specify a path"; r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE); + if (!r) { + return "Regex could not be compiled"; + } } else if (thiscmd->cmd_data) { /* */ r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE); + if (!r) { + return "Regex could not be compiled"; + } } else if (!strcmp(cmd->path, "/") == 0) { @@ -1707,10 +1713,16 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg) if (thiscmd->cmd_data) { /* */ r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED); + if (!r) { + return "Regex could not be compiled"; + } } else if (!strcmp(cmd->path, "~")) { cmd->path = ap_getword_conf(cmd->pool, &arg); r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED); + if (!r) { + return "Regex could not be compiled"; + } } /* initialize our config and fetch it */ @@ -1769,10 +1781,16 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg) if (thiscmd->cmd_data) { /* */ r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE); + if (!r) { + return "Regex could not be compiled"; + } } else if (!strcmp(cmd->path, "~")) { cmd->path = ap_getword_conf(cmd->pool, &arg); r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE); + if (!r) { + return "Regex could not be compiled"; + } } else { char *newpath;