]> granicus.if.org Git - apache/commitdiff
mod_setenvif: Compile the regex used by is_header_regex() only once
authorRainer Jung <rjung@apache.org>
Wed, 25 Jul 2012 21:29:15 +0000 (21:29 +0000)
committerRainer Jung <rjung@apache.org>
Wed, 25 Jul 2012 21:29:15 +0000 (21:29 +0000)
during startup This should save some memory, especially with .htaccess

Backport of r1343099.

Submitted by: sf
Reviewed by: rjung, jim
Backported by: rjung

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1365774 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/metadata/mod_setenvif.c

diff --git a/CHANGES b/CHANGES
index 03d1940cb3f97b710178c62e2558095dfa583371..9ebcccd595c9e53ad9865b553d1286e375e3a731 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,5 @@
                                                          -*- coding: utf-8 -*-
 
-<<<<<<< .working
 Changes with Apache 2.4.3
 
   *) SECURITY: CVE-2012-2687 (cve.mitre.org)
@@ -8,6 +7,10 @@ Changes with Apache 2.4.3
      possible XSS for a site where untrusted users can upload files to
      a location with MultiViews enabled. [Niels Heinen <heinenn google.com>]
 
+  *) mod_setenvif: Compile some global regex only once during startup.
+     This should save some memory, especially with .htaccess.
+     [Stefan Fritsch]
+
   *) core: Add the port number to the vhost's name in the scoreboard.
      [Stefan Fritsch]
 
diff --git a/STATUS b/STATUS
index affe97d86734d86fc34107365a0ae11c0bd00971..04c9968efbc41b92a954e336c8d6c6771e10bf61 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -88,11 +88,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-   * mod_setenvif: Compile the regex used by is_header_regex() only once
-     during startup This should save some memory, especially with .htaccess
-     trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1343099
-     2.4.x patch: trunk patch works
-     +1: rjung, jim, sf
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index 80825ccefa0729ccc2ace5491bc7302905be92ec..65214cd4f015057ff10f0bc7eeaba4439dd6e9e2 100644 (file)
@@ -165,17 +165,15 @@ static void *merge_setenvif_config(apr_pool_t *p, void *basev, void *overridesv)
 #define ICASE_MAGIC  ((void *)(&setenvif_module))
 #define SEI_MAGIC_HEIRLOOM "setenvif-phase-flag"
 
+static ap_regex_t *is_header_regex_regex;
+
 static int is_header_regex(apr_pool_t *p, const char* name)
 {
     /* If a Header name contains characters other than:
      *    -,_,[A-Z\, [a-z] and [0-9].
      * assume the header name is a regular expression.
      */
-    ap_regex_t *preg = ap_pregcomp(p, "^[-A-Za-z0-9_]*$",
-                                   (AP_REG_EXTENDED | AP_REG_NOSUB ));
-    ap_assert(preg != NULL);
-
-    if (ap_regexec(preg, name, 0, NULL, 0)) {
+    if (ap_regexec(is_header_regex_regex, name, 0, NULL, 0)) {
         return 1;
     }
 
@@ -633,6 +631,10 @@ static void register_hooks(apr_pool_t *p)
 {
     ap_hook_header_parser(match_headers, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_post_read_request(match_headers, NULL, NULL, APR_HOOK_MIDDLE);
+
+    is_header_regex_regex = ap_pregcomp(p, "^[-A-Za-z0-9_]*$",
+                                        (AP_REG_EXTENDED | AP_REG_NOSUB ));
+    ap_assert(is_header_regex_regex != NULL);
 }
 
 AP_DECLARE_MODULE(setenvif) =