]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
closes bpo-41235: Fix the error handling in SSLContext.load_dh_params() (GH-21385)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 8 Jul 2020 04:37:50 +0000 (21:37 -0700)
committerGitHub <noreply@github.com>
Wed, 8 Jul 2020 04:37:50 +0000 (21:37 -0700)
(cherry picked from commit aebc0495572c5bb85d2bd97d27cf93ab038b5a6a)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Misc/NEWS.d/next/Library/2020-07-07-21-56-26.bpo-41235.H2csMU.rst [new file with mode: 0644]
Modules/_ssl.c

diff --git a/Misc/NEWS.d/next/Library/2020-07-07-21-56-26.bpo-41235.H2csMU.rst b/Misc/NEWS.d/next/Library/2020-07-07-21-56-26.bpo-41235.H2csMU.rst
new file mode 100644 (file)
index 0000000..c55275b
--- /dev/null
@@ -0,0 +1 @@
+Fix the error handling in :meth:`ssl.SSLContext.load_dh_params`.
index 9fbaecb80739f95bece3575a55f0b08bb48d0fe7..8ee2c170368fdbf0cd68f2a99c07f2a08c0414f0 100644 (file)
@@ -4312,8 +4312,10 @@ _ssl__SSLContext_load_dh_params(PySSLContext *self, PyObject *filepath)
         }
         return NULL;
     }
-    if (SSL_CTX_set_tmp_dh(self->ctx, dh) == 0)
-        _setSSLError(NULL, 0, __FILE__, __LINE__);
+    if (!SSL_CTX_set_tmp_dh(self->ctx, dh)) {
+        DH_free(dh);
+        return _setSSLError(NULL, 0, __FILE__, __LINE__);
+    }
     DH_free(dh);
     Py_RETURN_NONE;
 }