Skip to content

Commit 1056648

Browse files
committed
Address review: rename recvmsg buffers_tuple, trim docstring, move NEWS to Library
- Rename sock_recvmsg_into's fast to buffers_tuple (per @vstinner). - Trim ReentrantMutationTests docstring to fit 80 columns. - This is a crash-robustness fix, not a security vulnerability; move the NEWS entry from Security/ to Library/.
1 parent 74b5139 commit 1056648

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

Lib/test/test_socket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7492,7 +7492,7 @@ def detach():
74927492

74937493

74947494
class ReentrantMutationTests(unittest.TestCase):
7495-
"""Regression tests for re-entrant mutation vulnerabilities in sendmsg/recvmsg_into.
7495+
"""Regression tests for re-entrant mutation in sendmsg/recvmsg_into.
74967496
74977497
These tests verify that mutating sequences during argument parsing
74987498
via __buffer__ protocol does not cause crashes.

Misc/NEWS.d/next/Security/2026-01-18-06-42-47.gh-issue-143988.MtLtCP.rst renamed to Misc/NEWS.d/next/Library/2026-01-18-06-42-47.gh-issue-143988.MtLtCP.rst

File renamed without changes.

Modules/socketmodule.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4521,19 +4521,19 @@ sock_recvmsg_into(PyObject *self, PyObject *args)
45214521
struct iovec *iovs = NULL;
45224522
Py_ssize_t i, nitems, nbufs = 0;
45234523
Py_buffer *bufs = NULL;
4524-
PyObject *buffers_arg, *fast, *retval = NULL;
4524+
PyObject *buffers_arg, *buffers_tuple, *retval = NULL;
45254525

45264526
if (!PyArg_ParseTuple(args, "O|ni:recvmsg_into",
45274527
&buffers_arg, &ancbufsize, &flags))
45284528
return NULL;
45294529

4530-
fast = PySequence_Tuple(buffers_arg);
4531-
if (fast == NULL) {
4530+
buffers_tuple = PySequence_Tuple(buffers_arg);
4531+
if (buffers_tuple == NULL) {
45324532
PyErr_SetString(PyExc_TypeError,
45334533
"recvmsg_into() argument 1 must be an iterable");
45344534
return NULL;
45354535
}
4536-
nitems = PyTuple_GET_SIZE(fast);
4536+
nitems = PyTuple_GET_SIZE(buffers_tuple);
45374537
if (nitems > INT_MAX) {
45384538
PyErr_SetString(PyExc_OSError, "recvmsg_into() argument 1 is too long");
45394539
goto finally;
@@ -4547,7 +4547,7 @@ sock_recvmsg_into(PyObject *self, PyObject *args)
45474547
goto finally;
45484548
}
45494549
for (; nbufs < nitems; nbufs++) {
4550-
if (!PyArg_Parse(PyTuple_GET_ITEM(fast, nbufs),
4550+
if (!PyArg_Parse(PyTuple_GET_ITEM(buffers_tuple, nbufs),
45514551
"w*;recvmsg_into() argument 1 must be an iterable "
45524552
"of single-segment read-write buffers",
45534553
&bufs[nbufs]))
@@ -4563,7 +4563,7 @@ sock_recvmsg_into(PyObject *self, PyObject *args)
45634563
PyBuffer_Release(&bufs[i]);
45644564
PyMem_Free(bufs);
45654565
PyMem_Free(iovs);
4566-
Py_DECREF(fast);
4566+
Py_DECREF(buffers_tuple);
45674567
return retval;
45684568
}
45694569

0 commit comments

Comments
 (0)