]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r105297, r105664 from trunk:
authorJoe Orton <jorton@apache.org>
Thu, 20 Jan 2005 09:33:02 +0000 (09:33 +0000)
committerJoe Orton <jorton@apache.org>
Thu, 20 Jan 2005 09:33:02 +0000 (09:33 +0000)
  * server/util_filter.c (ap_save_brigade): Handle an ENOTIMPL setaside
  function correctly.

  * server/util_filter.c (ap_save_brigade): Be more tolerant of a bucket
  type which neither implements ->setaside nor morphs on ->read, such as
  the mod_perl SV bucket type in mod_perl <1.99_17; defer returning an
  error in this case until after calling setaside on each bucket.

PR: 31247
Reviewed by: jorton, trawick, stoddard

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

CHANGES
STATUS
server/util_filter.c

diff --git a/CHANGES b/CHANGES
index a0db7eb28b151829fff284b21c22f6ea09f2fb71..085341083ee04264d018f38ec5285c8b30fbbf0b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
 Changes with Apache 2.0.53
 
+  *) Correct handling of certain bucket types in ap_save_brigade, fixing
+     possible segfaults in mod_cgi with #include virtual.  PR 31247.
+     [Joe Orton]
+
   *) Allow for the use of --with-module=foo:bar where the ./modules/foo
      directory is local only. Assumes, of course, that the required
      files are in ./modules/foo, but makes it easier to statically
diff --git a/STATUS b/STATUS
index 824a55414d11fc43dcec20af67397e3aef240cf0..ce970b5fd57efee80d404a5ba3b62e5b2539f7ae 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -178,11 +178,6 @@ PATCHES TO BACKPORT FROM 2.1
        PR 24437
        +1: minfrin, wrowe, jim
 
-    *) Fix ap_save_brigade's handling of ENOTIMPL setaside functions.
-         http://cvs.apache.org/viewcvs.cgi/httpd-2.0/server/util_filter.c?r1=1.100&r2=1.102
-       PR: 31247
-       +1: jorton, trawick, stoddard
-
     *) mod_headers: Support {...}s tag for SSL variable lookup.
        http://www.apache.org/~jorton/mod_headers-2.0-ssl.diff
        +1: jorton, trawick
index 9a4b9e512ed92fe4dd056da9df0e41ee0785b9e7..74acb41352546e2ec887cbf23503d53261f036d8 100644 (file)
@@ -518,7 +518,7 @@ AP_DECLARE(apr_status_t) ap_save_brigade(ap_filter_t *f,
                                          apr_bucket_brigade **b, apr_pool_t *p)
 {
     apr_bucket *e;
-    apr_status_t rv;
+    apr_status_t rv, srv = APR_SUCCESS;
 
     /* If have never stored any data in the filter, then we had better
      * create an empty bucket brigade so that we can concat.
@@ -529,15 +529,31 @@ AP_DECLARE(apr_status_t) ap_save_brigade(ap_filter_t *f,
     
     APR_RING_FOREACH(e, &(*b)->list, apr_bucket, link) {
         rv = apr_bucket_setaside(e, p);
-        if (rv != APR_SUCCESS
-            /* ### this ENOTIMPL will go away once we implement setaside
-               ### for all bucket types. */
-            && rv != APR_ENOTIMPL) {
-            return rv;
+
+        /* If the bucket type does not implement setaside, then
+         * (hopefully) morph it into a bucket type which does, and set
+         * *that* aside... */
+        if (rv == APR_ENOTIMPL) {
+            const char *s;
+            apr_size_t n;
+
+            rv = apr_bucket_read(e, &s, &n, APR_BLOCK_READ);
+            if (rv == APR_SUCCESS) {
+                rv = apr_bucket_setaside(e, p);
+            }
+        }
+
+        if (rv != APR_SUCCESS) {
+            srv = rv;
+            /* Return an error but still save the brigade if
+             * ->setaside() is really not implemented. */
+            if (rv != APR_ENOTIMPL) {
+                return rv;
+            }
         }
     }
     APR_BRIGADE_CONCAT(*saveto, *b);
-    return APR_SUCCESS;
+    return srv;
 }
 
 AP_DECLARE_NONSTD(apr_status_t) ap_filter_flush(apr_bucket_brigade *bb,