summaryrefslogtreecommitdiff
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 5e911e0584..ebaebf51d1 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -2494,6 +2494,12 @@ 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);
+ Py_XDECREF(addr);
+ PyErr_SetString(PyExc_ValueError,
+ "nbytes is greater than the length of the buffer");
+ return NULL;
}
readlen = sock_recvfrom_guts(s, buf, recvlen, flags, &addr);