Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5688222

Browse files
committed
merge 3.2 (#20246)
2 parents 80602e0 + fbf648e commit 5688222

4 files changed

Lines changed: 16 additions & 0 deletions

File tree

Lib/test/test_socket.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4538,6 +4538,14 @@ def testRecvFromIntoMemoryview(self):
45384538

45394539
_testRecvFromIntoMemoryview = _testRecvFromIntoArray
45404540

4541+
def testRecvFromIntoSmallBuffer(self):
4542+
# See issue #20246.
4543+
buf = bytearray(8)
4544+
self.assertRaises(ValueError, self.cli_conn.recvfrom_into, buf, 1024)
4545+
4546+
def _testRecvFromIntoSmallBuffer(self):
4547+
self.serv_conn.send(MSG*2048)
4548+
45414549

45424550
TIPC_STYPE = 2000
45434551
TIPC_LOWER = 200

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,7 @@ Eric V. Smith
11691169
Gregory P. Smith
11701170
Mark Smith
11711171
Roy Smith
1172+
Ryan Smith-Roberts
11721173
Rafal Smotrzyk
11731174
Eric Snow
11741175
Dirk Soede

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Library
4646
- Issue #20242: Fixed basicConfig() format strings for the alternative
4747
formatting styles. Thanks to kespindler for the bug report and patch.
4848

49+
- Issue #20246: Fix buffer overflow in socket.recvfrom_into.
50+
4951
- Issues #20206 and #5803: Fix edge case in email.quoprimime.encode where it
5052
truncated lines ending in a character needing encoding but no newline by
5153
using a more efficient algorithm that doesn't have the bug.

Modules/socketmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2935,6 +2935,11 @@ sock_recvfrom_into(PySocketSockObject *s, PyObject *args, PyObject* kwds)
29352935
if (recvlen == 0) {
29362936
/* If nbytes was not specified, use the buffer's length */
29372937
recvlen = buflen;
2938+
} else if (recvlen > buflen) {
2939+
PyBuffer_Release(&pbuf);
2940+
PyErr_SetString(PyExc_ValueError,
2941+
"nbytes is greater than the length of the buffer");
2942+
return NULL;
29382943
}
29392944

29402945
readlen = sock_recvfrom_guts(s, buf, recvlen, flags, &addr);

0 commit comments

Comments
 (0)