]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_ssl: Fix memory leak of OCSP stapling response.
authorYann Ylavic <ylavic@apache.org>
Thu, 27 Feb 2020 12:43:51 +0000 (12:43 +0000)
committerYann Ylavic <ylavic@apache.org>
Thu, 27 Feb 2020 12:43:51 +0000 (12:43 +0000)
The OCSP_RESPONSE is either ignored or serialized (i2d_OCSP_RESPONSE) in the
TLS response/handshake extension, so it must be freed.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1874577 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/ssl/ssl_util_stapling.c

diff --git a/CHANGES b/CHANGES
index d5d0b5eb16cba3087e873785040a53154fe80e83..ee8150654e390a82b1869fb6c0e242920fcc1b8d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.1
 
+  *) mod_ssl: Fix memory leak of OCSP stapling response. [Yann Ylavic]
+
   *) mod_authz_groupfile: Drop AH01666 from loglevel "error" to "info".
      PR64172.
 
index 8bb6e7c6c0a4c2b36abbda1a341ce2f9e801581a..a1bc6f9116c70cf031ef8bcdcb948d85689688b2 100644 (file)
@@ -873,15 +873,21 @@ static int stapling_cb(SSL *ssl, void *arg)
     if (rsp && ((ok == TRUE) || (mctx->stapling_return_errors == TRUE))) {
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01956)
                      "stapling_cb: setting response");
-        if (!stapling_set_response(ssl, rsp))
-            return SSL_TLSEXT_ERR_ALERT_FATAL;
-        return SSL_TLSEXT_ERR_OK;
+        if (!stapling_set_response(ssl, rsp)) {
+            rv = SSL_TLSEXT_ERR_ALERT_FATAL;
+        }
+        else {
+            rv = SSL_TLSEXT_ERR_OK;
+        }
     }
-    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01957)
-                 "stapling_cb: no suitable response available");
-
-    return SSL_TLSEXT_ERR_NOACK;
+    else {
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01957)
+                     "stapling_cb: no suitable response available");
+        rv = SSL_TLSEXT_ERR_NOACK;
+    }
+    OCSP_RESPONSE_free(rsp); /* NULL safe */
 
+    return rv;
 }
 
 apr_status_t modssl_init_stapling(server_rec *s, apr_pool_t *p,