From e2c188455f1ec2f4745722d94f5ada2e45173be4 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:29:10 +0100 Subject: [PATCH] [3.13] gh-126106: Fix `NULL` possible derefrence in `Modules/_ssl.c` (GH-126111) (#126116) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit gh-126106: Fix `NULL` possible derefrence in `Modules/_ssl.c` (GH-126111) (cherry picked from commit a64a1c920660b0c1e4dd5a9573004cd527e15184) Co-authored-by: sobolevn Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- .../Library/2024-10-29-10-58-52.gh-issue-126106.rlF798.rst | 1 + Modules/_ssl.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2024-10-29-10-58-52.gh-issue-126106.rlF798.rst diff --git a/Misc/NEWS.d/next/Library/2024-10-29-10-58-52.gh-issue-126106.rlF798.rst b/Misc/NEWS.d/next/Library/2024-10-29-10-58-52.gh-issue-126106.rlF798.rst new file mode 100644 index 000000000000..de989007b4c3 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-10-29-10-58-52.gh-issue-126106.rlF798.rst @@ -0,0 +1 @@ +Fixes a possible ``NULL`` pointer dereference in :mod:`ssl`. diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 54900894cc88..db4e9c48df57 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -5206,14 +5206,14 @@ PySSLSession_dealloc(PySSLSession *self) static PyObject * PySSLSession_richcompare(PyObject *left, PyObject *right, int op) { - int result; - PyTypeObject *sesstype = ((PySSLSession*)left)->ctx->state->PySSLSession_Type; - if (left == NULL || right == NULL) { PyErr_BadInternalCall(); return NULL; } + int result; + PyTypeObject *sesstype = ((PySSLSession*)left)->ctx->state->PySSLSession_Type; + if (!Py_IS_TYPE(left, sesstype) || !Py_IS_TYPE(right, sesstype)) { Py_RETURN_NOTIMPLEMENTED; } -- 2.47.3