summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-05-28 13:27:08 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-05-28 13:27:08 (GMT)
commit281945f42720e61bd4c373b37e379713b8a10037 (patch)
tree673c51692f683f3971930fddb62d8e6d556207fc /Modules
parent5758fa78d0af2ca4cbbb819797372d055bb7faa1 (diff)
parent37a79a12d1a9c337e0a8f7a12f11600c44be824f (diff)
downloadcpython-281945f42720e61bd4c373b37e379713b8a10037.zip
cpython-281945f42720e61bd4c373b37e379713b8a10037.tar.gz
cpython-281945f42720e61bd4c373b37e379713b8a10037.tar.bz2
Issue #18025: Fixed a segfault in io.BufferedIOBase.readinto() when raw
stream's read() returns more bytes than requested.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_io/bufferedio.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 943aacb..b0bbc62 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -69,6 +69,14 @@ bufferediobase_readinto(PyObject *self, PyObject *args)
}
len = Py_SIZE(data);
+ if (len > buf.len) {
+ PyErr_Format(PyExc_ValueError,
+ "read() returned too much data: "
+ "%zd bytes requested, %zd returned",
+ buf.len, len);
+ Py_DECREF(data);
+ goto error;
+ }
memcpy(buf.buf, PyBytes_AS_STRING(data), len);
PyBuffer_Release(&buf);