]> granicus.if.org Git - python/commitdiff
Test for negative buffer sizes. Fixes #482871.
authorMartin v. Löwis <martin@v.loewis.de>
Mon, 19 Nov 2001 10:41:26 +0000 (10:41 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 19 Nov 2001 10:41:26 +0000 (10:41 +0000)
Modules/socketmodule.c

index 2a62f5d1dceee6e89e0e7b4dc8b92017e9f813da..17f7461429abd954949a9a52b0b5b7bd65ee3e49 100644 (file)
@@ -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;