Test for negative buffer sizes. Fixes #482871.
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 2a62f5d..17f7461 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1481,6 +1481,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;