Skip to content

Commit 6117230

Browse files
author
Andre Malo
committed
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
1 parent ff75ae6 commit 6117230

7 files changed

Lines changed: 36 additions & 16 deletions

File tree

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Changes with Apache 2.0.50
22

3+
*) Fix a bunch of cases where the return code of the regex compiler
4+
was not checked properly. This affects: mod_setenvif, mod_usertrack,
5+
mod_proxy, mod_proxy_ftp and core. PR 28218. [Andr� Malo]
6+
37
*) mod_ssl: Fix a potential segfault in the 'shmcb' session cache for
48
small cache sizes. PR 27751. [Geoff Thorpe <geoff geoffthorpe.net>]
59

STATUS

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
APACHE 2.0 STATUS: -*-text-*-
2-
Last modified at [$Date: 2004/06/02 14:30:40 $]
2+
Last modified at [$Date: 2004/06/02 22:40:21 $]
33

44
Release:
55

@@ -179,17 +179,6 @@ PATCHES TO BACKPORT FROM 2.1
179179
modules/loggers/mod_log_config.c: r1.116
180180
+1: nd
181181

182-
*) Fix a bunch of cases where the return code of the regex compiler
183-
was not checked properly. The 1.3-diff is here:
184-
http://www.apache.org/~nd/regex-return-1.3.diff (only core and
185-
mod_usertrack affected). PR 28218.
186-
modules/metadata/mod_setenvif.c: r1.51
187-
modules/metadata/mod_usertrack.c: r1.52
188-
modules/proxy/mod_proxy.c: r1.99
189-
modules/proxy/proxy_ftp.c: r1.140
190-
server/core.c: r1.272
191-
+1: nd, trawick, jorton
192-
193182
*) mod_usertrack: Escape the cookie_name before pasting into the regexp.
194183
(2.0 + 1.3)
195184
modules/metadata/mod_usertrack.c: r1.51

modules/metadata/mod_setenvif.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,12 @@ static int is_header_regex(apr_pool_t *p, const char* name)
174174
*/
175175
regex_t *preg = ap_pregcomp(p, "^[-A-Za-z0-9_]*$",
176176
(REG_EXTENDED | REG_NOSUB ));
177-
if (preg) {
178-
if (ap_regexec(preg, name, 0, NULL, 0)) {
179-
return 1;
180-
}
177+
ap_assert(preg != NULL);
178+
179+
if (ap_regexec(preg, name, 0, NULL, 0)) {
180+
return 1;
181181
}
182+
182183
return 0;
183184
}
184185

modules/metadata/mod_usertrack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ static void set_and_comp_regexp(cookie_dir_rec *dcfg,
168168
dcfg->regexp_string = apr_pstrcat(p, "^", cookie_name, "=([^;]+)|;[ \t]+", cookie_name, "=([^;]+)", NULL);
169169

170170
dcfg->regexp = ap_pregcomp(p, dcfg->regexp_string, REG_EXTENDED);
171+
ap_assert(dcfg->regexp != NULL);
171172
}
172173

173174
static int spot_cookie(request_rec *r)

modules/proxy/mod_proxy.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,9 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg)
945945
*/
946946
if (thiscmd->cmd_data) { /* <ProxyMatch> */
947947
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
948+
if (!r) {
949+
return "Regex could not be compiled";
950+
}
948951
}
949952
else if (!strcmp(cmd->path, "~")) {
950953
cmd->path = ap_getword_conf(cmd->pool, &arg);
@@ -953,6 +956,9 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg)
953956
if (strncasecmp(cmd->path, "proxy:", 6))
954957
cmd->path += 6;
955958
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
959+
if (!r) {
960+
return "Regex could not be compiled";
961+
}
956962
}
957963

958964
/* initialize our config and fetch it */

modules/proxy/proxy_ftp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *in)
430430

431431
/* Compile the output format of "ls -s1" as a fallback for non-unix ftp listings */
432432
re = ap_pregcomp(p, LS_REG_PATTERN, REG_EXTENDED);
433+
ap_assert(re != NULL);
433434

434435
/* get a complete line */
435436
/* if the buffer overruns - throw data away */

server/core.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,9 +1623,15 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
16231623
if (!cmd->path)
16241624
return "<Directory ~ > block must specify a path";
16251625
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
1626+
if (!r) {
1627+
return "Regex could not be compiled";
1628+
}
16261629
}
16271630
else if (thiscmd->cmd_data) { /* <DirectoryMatch> */
16281631
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
1632+
if (!r) {
1633+
return "Regex could not be compiled";
1634+
}
16291635
}
16301636
else if (!strcmp(cmd->path, "/") == 0)
16311637
{
@@ -1707,10 +1713,16 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg)
17071713

17081714
if (thiscmd->cmd_data) { /* <LocationMatch> */
17091715
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
1716+
if (!r) {
1717+
return "Regex could not be compiled";
1718+
}
17101719
}
17111720
else if (!strcmp(cmd->path, "~")) {
17121721
cmd->path = ap_getword_conf(cmd->pool, &arg);
17131722
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
1723+
if (!r) {
1724+
return "Regex could not be compiled";
1725+
}
17141726
}
17151727

17161728
/* initialize our config and fetch it */
@@ -1769,10 +1781,16 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg)
17691781

17701782
if (thiscmd->cmd_data) { /* <FilesMatch> */
17711783
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
1784+
if (!r) {
1785+
return "Regex could not be compiled";
1786+
}
17721787
}
17731788
else if (!strcmp(cmd->path, "~")) {
17741789
cmd->path = ap_getword_conf(cmd->pool, &arg);
17751790
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
1791+
if (!r) {
1792+
return "Regex could not be compiled";
1793+
}
17761794
}
17771795
else {
17781796
char *newpath;

0 commit comments

Comments
 (0)