From fba64e1ecaa62799ee62e5c9988d2496ed6125d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Mon, 19 Nov 2001 10:41:26 +0000 Subject: [PATCH] Test for negative buffer sizes. Fixes #482871. --- Modules/socketmodule.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 2a62f5d1dc..17f7461429 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1481,6 +1481,11 @@ PySocketSock_recv(PySocketSockObject *s, PyObject *args) PyObject *buf; if (!PyArg_ParseTuple(args, "i|i:recv", &len, &flags)) return NULL; + if (len < 0) { + PyErr_SetString(PyExc_ValueError, + "negative buffersize in connect"); + return NULL; + } buf = PyString_FromStringAndSize((char *) 0, len); if (buf == NULL) return NULL; -- 2.50.0