]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Fix a bunch of cases where the return code of the regex compiler
authorAndré Malo <nd@apache.org>
Wed, 2 Jun 2004 22:40:23 +0000 (22:40 +0000)
committerAndré Malo <nd@apache.org>
Wed, 2 Jun 2004 22:40:23 +0000 (22:40 +0000)
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

CHANGES
STATUS
modules/metadata/mod_setenvif.c
modules/metadata/mod_usertrack.c
modules/proxy/mod_proxy.c
modules/proxy/proxy_ftp.c
server/core.c

diff --git a/CHANGES b/CHANGES
index 255de92ac4b1d7f5eefad0dafc8f5eaa6572b135..487369205096b119e721cb91259a28d48df2392b 100644 (file)
--- 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 <geoff geoffthorpe.net>]
 
diff --git a/STATUS b/STATUS
index 6098b84bdfb3816a6a67d1b346403c8e90d0275c..db9784078204bfa59343f85abd8d0fdc3ac9d033 100644 (file)
--- 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
index 7ac6a6f08bb3bd02dbd10ebafb6c705f38992f88..7608871d1b4fa1bc0f10fa60baacbebcb20676a2 100644 (file)
@@ -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;
 }
 
index 6a345a76f470388f1174f03578dfc51d86883ef1..805d51e8f504a32df2d5e6c121fa4cc0f80d9233 100644 (file)
@@ -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)
index 78a0e12ce454751140b5bc55a63f77c2725b9077..069c97c3465e54cc4c164360a08aa7140cd9198b 100644 (file)
@@ -945,6 +945,9 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg)
      */
     if (thiscmd->cmd_data) { /* <ProxyMatch> */
         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 */
index 11c65c138ffe2fde4076abd547136ceeda5e2b28..fdd9172566f613b92d1cf403f36ac2edc377ce6a 100644 (file)
@@ -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 */
index 7d747098b2182ad3e46c3d2d3fac6b86685646db..409e7b188f3810c2e9c183567ebf9c8be0742a7c 100644 (file)
@@ -1623,9 +1623,15 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
         if (!cmd->path)
             return "<Directory ~ > 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) { /* <DirectoryMatch> */
         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) { /* <LocationMatch> */
         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) { /* <FilesMatch> */
         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;