]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
backport of the mod_mem_cache apr_table_copy pool ancestry abuse
authorEric Covener <covener@apache.org>
Thu, 12 Jul 2007 13:44:42 +0000 (13:44 +0000)
committerEric Covener <covener@apache.org>
Thu, 12 Jul 2007 13:44:42 +0000 (13:44 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@555626 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/cache/mod_mem_cache.c

diff --git a/CHANGES b/CHANGES
index 4f558c24e390de8d9939c6b094dfc7924b1c25e5..fd9542fb1098e7901a6807e3e78b2034967bc848 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -12,6 +12,11 @@ Changes with Apache 2.2.5
   *) mod_cache: Correctly handle HEAD requests on expired cache content.
      PR 41230.  [Niklas Edmundsson <nikke acc.umu.se>]
 
+  *) SECURITY: CVE-2007-1862 (cve.mitre.org)
+     mod_mem_cache: Copy headers into longer lived storage; header names and
+     values could previously point to cleaned up storage
+     PR 41551 [Davi Arnaut <davi haxent.com.br>]
+
   *) mod_cache: Let Cache-Control max-age set the expiration of the cached
      representation if Expires is not set.  [Justin Erenkrantz]
 
diff --git a/STATUS b/STATUS
index 2a13b5f3136be956d4d2b1470c3e3cefd5be835a..78ad09339717b20254db83c17a3eb6415471ee36 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -105,17 +105,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
         http://svn.apache.org/viewvc?view=rev&revision=546128
       +1: jfclere, jim, rpluem
 
-    * SECURITY: CVE-2007-1862 (cve.mitre.org)
-      mod_mem_cache: Copy headers into longer lived storage; header names and
-      values could previously point to cleaned up storage
-      PR 41551
-      Trunk version of patch:
-        http://svn.apache.org/viewvc?view=rev&revision=543515
-      2.2.x version of patch:
-        http://people.apache.org/~covener/2.2.x-mod_memcache-poolmgmt.diff
-      +1: covener, jorton, rpluem
-
-
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
 
     * ApacheMonitor: Fix Windows Vista detection.
index ea9c45d35692d12dd7d926ed55eb94357f930d09..589ed17a160398a693d73f4fc74ae5eea8284eef 100644 (file)
@@ -539,12 +539,28 @@ static int remove_url(cache_handle_t *h, apr_pool_t *p)
     return OK;
 }
 
+static apr_table_t *deep_table_copy(apr_pool_t *p, const apr_table_t *table)
+{
+    const apr_array_header_t *array = apr_table_elts(table);
+    apr_table_entry_t *elts = (apr_table_entry_t *) array->elts;
+    apr_table_t *copy = apr_table_make(p, array->nelts);
+    int i;
+
+    for (i = 0; i < array->nelts; i++) {
+        if (elts[i].key) {  
+            apr_table_add(copy, elts[i].key, elts[i].val);
+        }
+    }
+
+    return copy;
+}
+
 static apr_status_t recall_headers(cache_handle_t *h, request_rec *r)
 {
     mem_cache_object_t *mobj = (mem_cache_object_t*) h->cache_obj->vobj;
 
-    h->req_hdrs = apr_table_copy(r->pool, mobj->req_hdrs);
-    h->resp_hdrs = apr_table_copy(r->pool, mobj->header_out);
+    h->req_hdrs = deep_table_copy(r->pool, mobj->req_hdrs);
+    h->resp_hdrs = deep_table_copy(r->pool, mobj->header_out);
 
     return OK;
 }
@@ -585,7 +601,7 @@ static apr_status_t store_headers(cache_handle_t *h, request_rec *r, cache_info
      * - The original response headers (for returning with a cached response)
      * - The body of the message
      */
-    mobj->req_hdrs = apr_table_copy(mobj->pool, r->headers_in);
+    mobj->req_hdrs = deep_table_copy(mobj->pool, r->headers_in);
 
     /* Precompute how much storage we need to hold the headers */
     headers_out = ap_cache_cacheable_hdrs_out(r->pool, r->headers_out,
@@ -599,7 +615,7 @@ static apr_status_t store_headers(cache_handle_t *h, request_rec *r, cache_info
     }
 
     headers_out = apr_table_overlay(r->pool, headers_out, r->err_headers_out);
-    mobj->header_out = apr_table_copy(mobj->pool, headers_out);
+    mobj->header_out = deep_table_copy(mobj->pool, headers_out);
 
     /* Init the info struct */
     obj->info.status = info->status;