You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2020/02/07 16:56:40 UTC

svn commit: r1873742 - in /httpd/httpd/branches/2.4.x: ./ CHANGES modules/arch/unix/mod_systemd.c modules/generators/mod_cgi.c modules/generators/mod_cgid.c

Author: jorton
Date: Fri Feb  7 16:56:40 2020
New Revision: 1873742

URL: http://svn.apache.org/viewvc?rev=1873742&view=rev
Log:
Merge r1867970 from trunk:

* modules/generators/cgi_common.h (discard_script_output): Simplify
  slightly and ensure constant rather than unlimited memory
  consumption when discarding CGI script output (for e.g. a redirect
  response).

PR: 64096
Submitted by: jorton
Reviewed by: jorton, covener, rpluem

Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/CHANGES
    httpd/httpd/branches/2.4.x/modules/arch/unix/mod_systemd.c   (props changed)
    httpd/httpd/branches/2.4.x/modules/generators/mod_cgi.c
    httpd/httpd/branches/2.4.x/modules/generators/mod_cgid.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1867970

Modified: httpd/httpd/branches/2.4.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1873742&r1=1873741&r2=1873742&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Fri Feb  7 16:56:40 2020
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.4.42
 
+  *) mod_cgi, mod_cgid: Fix a memory leak in some error cases with large script
+     output.  PR 64096.  [Joe Orton]
+
   *) config: Speed up graceful restarts by using pre-hashed command table. PR 64066.
      [Giovanni Bechis <giovanni paclan.it>, Jim Jagielski]
 

Propchange: httpd/httpd/branches/2.4.x/modules/arch/unix/mod_systemd.c
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk/modules/arch/unix/mod_systemd.c:r1867970

Modified: httpd/httpd/branches/2.4.x/modules/generators/mod_cgi.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/generators/mod_cgi.c?rev=1873742&r1=1873741&r2=1873742&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/generators/mod_cgi.c (original)
+++ httpd/httpd/branches/2.4.x/modules/generators/mod_cgi.c Fri Feb  7 16:56:40 2020
@@ -541,19 +541,15 @@ static void discard_script_output(apr_bu
     apr_bucket *e;
     const char *buf;
     apr_size_t len;
-    apr_status_t rv;
 
     for (e = APR_BRIGADE_FIRST(bb);
-         e != APR_BRIGADE_SENTINEL(bb);
-         e = APR_BUCKET_NEXT(e))
+         e != APR_BRIGADE_SENTINEL(bb) && !APR_BUCKET_IS_EOS(e);
+         e = APR_BRIGADE_FIRST(bb))
     {
-        if (APR_BUCKET_IS_EOS(e)) {
-            break;
-        }
-        rv = apr_bucket_read(e, &buf, &len, APR_BLOCK_READ);
-        if (rv != APR_SUCCESS) {
+        if (apr_bucket_read(e, &buf, &len, APR_BLOCK_READ)) {
             break;
         }
+        apr_bucket_delete(e);
     }
 }
 

Modified: httpd/httpd/branches/2.4.x/modules/generators/mod_cgid.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/generators/mod_cgid.c?rev=1873742&r1=1873741&r2=1873742&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/generators/mod_cgid.c (original)
+++ httpd/httpd/branches/2.4.x/modules/generators/mod_cgid.c Fri Feb  7 16:56:40 2020
@@ -1275,19 +1275,15 @@ static void discard_script_output(apr_bu
     apr_bucket *e;
     const char *buf;
     apr_size_t len;
-    apr_status_t rv;
 
     for (e = APR_BRIGADE_FIRST(bb);
-         e != APR_BRIGADE_SENTINEL(bb);
-         e = APR_BUCKET_NEXT(e))
+         e != APR_BRIGADE_SENTINEL(bb) && !APR_BUCKET_IS_EOS(e);
+         e = APR_BRIGADE_FIRST(bb))
     {
-        if (APR_BUCKET_IS_EOS(e)) {
-            break;
-        }
-        rv = apr_bucket_read(e, &buf, &len, APR_BLOCK_READ);
-        if (rv != APR_SUCCESS) {
+        if (apr_bucket_read(e, &buf, &len, APR_BLOCK_READ)) {
             break;
         }
+        apr_bucket_delete(e);
     }
 }