]> granicus.if.org Git - apache/commitdiff
Fix a bunch of cases where the return code of the regex compiler
authorAndré Malo <nd@apache.org>
Sat, 10 Apr 2004 13:57:39 +0000 (13:57 +0000)
committerAndré Malo <nd@apache.org>
Sat, 10 Apr 2004 13:57:39 +0000 (13:57 +0000)
was not checked properly. This affects: mod_setenvif, mod_usertrack,
mod_proxy, mod_proxy_ftp and core.

PR: 28218

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@103328 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
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 42d0c23a86f2b0f3560145ecdba83be834033d8e..65433ebcb6acd42699a7ed2500c25e66b53adc91 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) 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_usertrack: Escape the cookie name before pasting into the
      regexp.  [André Malo]
 
index 78eb5c76d64b641426c33f27d9090a63ee49db4a..bf2e0ec02ee80669264e4edf5abf13037e798d3f 100644 (file)
@@ -172,11 +172,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 9c00a9a1d0c4c707a9e5711f8b6305095e980179..a70761799710994d0926448d046b6ad428fe075c 100644 (file)
@@ -200,6 +200,7 @@ static void set_and_comp_regexp(cookie_dir_rec *dcfg,
                                       "=([^;,]+)", NULL);
 
     dcfg->regexp = ap_pregcomp(p, dcfg->regexp_string, REG_EXTENDED);
+    ap_assert(dcfg->regexp != NULL);
 }
 
 static int spot_cookie(request_rec *r)
index 2bb4b41cac1b4900e155e218028d6be8a71d9b7c..78c59083f3cf0b761fb06c0e9c0238534be1b964 100644 (file)
@@ -946,6 +946,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);
@@ -954,6 +957,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 f376ba96b952318c79970de90b9f6b356156948f..ad29d08463bf928c5df495c132b7c329bef86fd3 100644 (file)
@@ -427,6 +427,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 302aa0798db5467dbe438902738b10d0ca0d3571..915f752d6c5b51061008810a5433a90df3d89f14 100644 (file)
@@ -1651,9 +1651,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)
     {
@@ -1735,10 +1741,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 */
@@ -1797,10 +1809,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;