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

Skip to content

Commit fba64e1

Browse files
committed
Test for negative buffer sizes. Fixes #482871.
1 parent 27ae311 commit fba64e1

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Modules/socketmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,11 @@ PySocketSock_recv(PySocketSockObject *s, PyObject *args)
14811481
PyObject *buf;
14821482
if (!PyArg_ParseTuple(args, "i|i:recv", &len, &flags))
14831483
return NULL;
1484+
if (len < 0) {
1485+
PyErr_SetString(PyExc_ValueError,
1486+
"negative buffersize in connect");
1487+
return NULL;
1488+
}
14841489
buf = PyString_FromStringAndSize((char *) 0, len);
14851490
if (buf == NULL)
14861491
return NULL;

0 commit comments

Comments
 (0)