You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2021/12/03 15:34:16 UTC

svn commit: r1895555 - in /httpd/httpd/branches/2.4.x: ./ CHANGES server/connection.c

Author: ylavic
Date: Fri Dec  3 15:34:16 2021
New Revision: 1895555

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

*) core: Be safe with ap_lingering_close() called with a socket NULL-ed.

PR 65627. 

mod_itk seems to:
  ap_set_core_module_config(c->conn_config, NULL)
before calling ap_lingering_close(), causing a crash after r1891721.
Until we have an API to no-op ap_lingering_close(), let's be safe.

* server/connection.c(ap_start_lingering_close):
  The socket should not be NULL here, add an assertion.

* server/connection.c(ap_lingering_close):
  Set c->aborted if the socket is NULL, and give up.


Submitted by: acmondor <bz.apache.org acmondor.ca>, ylavic
Reviewed by: ylavic, icing, rpluem
Github: closes #277

Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/CHANGES
    httpd/httpd/branches/2.4.x/server/connection.c

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

Modified: httpd/httpd/branches/2.4.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1895555&r1=1895554&r2=1895555&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Fri Dec  3 15:34:16 2021
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.4.52
 
+  *) core: Be safe with ap_lingering_close() called with a socket NULL-ed by
+     a third-party module.  PR 65627.
+     [acmondor <bz.apache.org acmondor.ca>, Yann Ylavic]
+
   *) mod_md: Fix memory leak in case of failures to load the private key.
      PR 65620 [ Filipe Casal <fi...@trailofbits.com> ]
 

Modified: httpd/httpd/branches/2.4.x/server/connection.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/connection.c?rev=1895555&r1=1895554&r2=1895555&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/connection.c (original)
+++ httpd/httpd/branches/2.4.x/server/connection.c Fri Dec  3 15:34:16 2021
@@ -122,9 +122,7 @@ AP_DECLARE(int) ap_start_lingering_close
 {
     apr_socket_t *csd = ap_get_conn_socket(c);
 
-    if (!csd) {
-        return 1;
-    }
+    ap_assert(csd != NULL);
 
     if (ap_prep_lingering_close(c)) {
         return 1;
@@ -155,6 +153,15 @@ AP_DECLARE(void) ap_lingering_close(conn
     apr_time_t now, timeup = 0;
     apr_socket_t *csd = ap_get_conn_socket(c);
 
+    if (!csd) {
+        /* Be safe with third-party modules that:
+         *   ap_set_core_module_config(c->conn_config, NULL)
+         * to no-op ap_lingering_close().
+         */
+        c->aborted = 1;
+        return;
+    }
+
     if (ap_start_lingering_close(c)) {
         apr_socket_close(csd);
         return;