Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.11] gh-106831: Fix NULL check of d2i_SSL_SESSION() result in _ssl.c (GH-106832) #106836

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix potential missing ``NULL`` check of ``d2i_SSL_SESSION`` result in
``_ssl.c``.
7 changes: 4 additions & 3 deletions Modules/_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2800,7 +2800,7 @@
/* get length */
slen = i2d_SSL_SESSION(session, NULL);
if (slen == 0 || slen > 0xFF00) {
PyErr_SetString(PyExc_ValueError, "i2d() failed.");
PyErr_SetString(PyExc_ValueError, "i2d() failed");
goto error;
}
if ((senc = PyMem_Malloc(slen)) == NULL) {
Expand All @@ -2809,12 +2809,13 @@
}
p = senc;
if (!i2d_SSL_SESSION(session, &p)) {
PyErr_SetString(PyExc_ValueError, "i2d() failed.");
PyErr_SetString(PyExc_ValueError, "i2d() failed");
goto error;
}
const_p = senc;
newsession = d2i_SSL_SESSION(NULL, &const_p, slen);
if (session == NULL) {
if (newsession == NULL) {
PyErr_SetString(PyExc_ValueError, "d2i() failed");
goto error;
}
PyMem_Free(senc);
Expand Down Expand Up @@ -3616,7 +3617,7 @@
static PyObject *
get_options(PySSLContext *self, void *c)
{
return PyLong_FromLong(SSL_CTX_get_options(self->ctx));

Check warning on line 3620 in Modules/_ssl.c

View workflow job for this annotation

GitHub Actions / Windows (x64)

'function': conversion from 'uint64_t' to 'long', possible loss of data [D:\a\cpython\cpython\PCbuild\_ssl.vcxproj]

Check warning on line 3620 in Modules/_ssl.c

View workflow job for this annotation

GitHub Actions / Windows (x64)

'function': conversion from 'uint64_t' to 'long', possible loss of data [D:\a\cpython\cpython\PCbuild\_ssl.vcxproj]
}

static int
Expand All @@ -3630,7 +3631,7 @@

if (!PyArg_Parse(arg, "l", &new_opts))
return -1;
opts = SSL_CTX_get_options(self->ctx);

Check warning on line 3634 in Modules/_ssl.c

View workflow job for this annotation

GitHub Actions / Windows (x64)

'=': conversion from 'uint64_t' to 'long', possible loss of data [D:\a\cpython\cpython\PCbuild\_ssl.vcxproj]

Check warning on line 3634 in Modules/_ssl.c

View workflow job for this annotation

GitHub Actions / Windows (x64)

'=': conversion from 'uint64_t' to 'long', possible loss of data [D:\a\cpython\cpython\PCbuild\_ssl.vcxproj]
clear = opts & ~new_opts;
set = ~opts & new_opts;

Expand Down