mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-111178: fix UBSan failures in Modules/_ssl.c (GH-130719)
* fix UBSan failures for `PySSLContext`, `PySSLSocket`, `PySSLMemoryBIO`, `PySSLSession`
This commit is contained in:
parent
a45f25361d
commit
e708ac8dd4
3 changed files with 67 additions and 35 deletions
|
|
@ -85,7 +85,9 @@ _PySSL_msg_callback(int write_p, int version, int content_type,
|
|||
|
||||
|
||||
static PyObject *
|
||||
_PySSLContext_get_msg_callback(PySSLContext *self, void *c) {
|
||||
_PySSLContext_get_msg_callback(PyObject *op, void *Py_UNUSED(closure))
|
||||
{
|
||||
PySSLContext *self = PySSLContext_CAST(op);
|
||||
if (self->msg_cb != NULL) {
|
||||
return Py_NewRef(self->msg_cb);
|
||||
} else {
|
||||
|
|
@ -94,7 +96,10 @@ _PySSLContext_get_msg_callback(PySSLContext *self, void *c) {
|
|||
}
|
||||
|
||||
static int
|
||||
_PySSLContext_set_msg_callback(PySSLContext *self, PyObject *arg, void *c) {
|
||||
_PySSLContext_set_msg_callback(PyObject *op, PyObject *arg,
|
||||
void *Py_UNUSED(closure))
|
||||
{
|
||||
PySSLContext *self = PySSLContext_CAST(op);
|
||||
Py_CLEAR(self->msg_cb);
|
||||
if (arg == Py_None) {
|
||||
SSL_CTX_set_msg_callback(self->ctx, NULL);
|
||||
|
|
@ -153,7 +158,9 @@ _PySSL_keylog_callback(const SSL *ssl, const char *line)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
_PySSLContext_get_keylog_filename(PySSLContext *self, void *c) {
|
||||
_PySSLContext_get_keylog_filename(PyObject *op, void *Py_UNUSED(closure))
|
||||
{
|
||||
PySSLContext *self = PySSLContext_CAST(op);
|
||||
if (self->keylog_filename != NULL) {
|
||||
return Py_NewRef(self->keylog_filename);
|
||||
} else {
|
||||
|
|
@ -162,7 +169,10 @@ _PySSLContext_get_keylog_filename(PySSLContext *self, void *c) {
|
|||
}
|
||||
|
||||
static int
|
||||
_PySSLContext_set_keylog_filename(PySSLContext *self, PyObject *arg, void *c) {
|
||||
_PySSLContext_set_keylog_filename(PyObject *op, PyObject *arg,
|
||||
void *Py_UNUSED(closure))
|
||||
{
|
||||
PySSLContext *self = PySSLContext_CAST(op);
|
||||
FILE *fp;
|
||||
/* Reset variables and callback first */
|
||||
SSL_CTX_set_keylog_callback(self->ctx, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue