diff Modules/socketmodule.c @ 21532:e69b21f2529e 2.1

backport of 1.196: socket.recv(-1) fixup.
author Anthony Baxter <anthonybaxter@gmail.com>
date Sun, 23 Dec 2001 01:44:49 +0000
parents 8d4b6642a604
children 355e46cc124f
line wrap: on
line diff
--- a/Modules/socketmodule.c	Sun Dec 23 01:37:33 2001 +0000
+++ b/Modules/socketmodule.c	Sun Dec 23 01:44:49 2001 +0000
@@ -1324,6 +1324,11 @@
 	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;