diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-01-14 04:12:55 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-01-14 04:12:55 (GMT) |
commit | 5688222907583833837f2f0e92205f17fb92d436 (patch) | |
tree | 97f45bbb2e1003b76bfe4edb05a61b5a28220cd5 | |
parent | 80602e0e1b543d9f1e08fced125b0ea6c67cdf4b (diff) | |
parent | fbf648ebba32bbc5aa571a4b09e2062a65fd2492 (diff) | |
download | cpython-5688222907583833837f2f0e92205f17fb92d436.zip cpython-5688222907583833837f2f0e92205f17fb92d436.tar.gz cpython-5688222907583833837f2f0e92205f17fb92d436.tar.bz2 |
merge 3.2 (#20246)
-rw-r--r-- | Lib/test/test_socket.py | 8 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Modules/socketmodule.c | 5 |
4 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index fc04aba..2df6dd6 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -4538,6 +4538,14 @@ class BufferIOTest(SocketConnectedTest): _testRecvFromIntoMemoryview = _testRecvFromIntoArray + def testRecvFromIntoSmallBuffer(self): + # See issue #20246. + buf = bytearray(8) + self.assertRaises(ValueError, self.cli_conn.recvfrom_into, buf, 1024) + + def _testRecvFromIntoSmallBuffer(self): + self.serv_conn.send(MSG*2048) + TIPC_STYPE = 2000 TIPC_LOWER = 200 @@ -1169,6 +1169,7 @@ Eric V. Smith Gregory P. Smith Mark Smith Roy Smith +Ryan Smith-Roberts Rafal Smotrzyk Eric Snow Dirk Soede @@ -46,6 +46,8 @@ Library - Issue #20242: Fixed basicConfig() format strings for the alternative formatting styles. Thanks to kespindler for the bug report and patch. +- Issue #20246: Fix buffer overflow in socket.recvfrom_into. + - Issues #20206 and #5803: Fix edge case in email.quoprimime.encode where it truncated lines ending in a character needing encoding but no newline by using a more efficient algorithm that doesn't have the bug. diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 3bddaa5..e371815 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2935,6 +2935,11 @@ sock_recvfrom_into(PySocketSockObject *s, PyObject *args, PyObject* kwds) if (recvlen == 0) { /* If nbytes was not specified, use the buffer's length */ recvlen = buflen; + } else if (recvlen > buflen) { + PyBuffer_Release(&pbuf); + PyErr_SetString(PyExc_ValueError, + "nbytes is greater than the length of the buffer"); + return NULL; } readlen = sock_recvfrom_guts(s, buf, recvlen, flags, &addr); |