diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-03-31 18:56:11 +0000 |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-03-31 18:56:11 +0000 |
commit | 65407fb7344d4ecdeecb8733831365c23a713ab6 (patch) | |
tree | a9b6176ba4cbda35577e3b437a3ab2732cefde16 /Modules/socketmodule.c | |
parent | ef9e09e737914c9c5d91cf177df43fdad4be6000 (diff) | |
download | cpython-git-65407fb7344d4ecdeecb8733831365c23a713ab6.tar.gz |
Backport 54594:
Fix SF #1688393, sock.recvfrom(-24) crashes
Also fix some method names that were copied incorrectly (trunk fixed).
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 9f833271d8..f4d2ae67e8 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2356,14 +2356,14 @@ sock_recv_into(PySocketSockObject *s, PyObject *args, PyObject *kwds) int buflen; /* Get the buffer's memory */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "w#|ii:recv", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "w#|ii:recv_into", kwlist, &buf, &buflen, &recvlen, &flags)) return NULL; assert(buf != 0 && buflen > 0); if (recvlen < 0) { PyErr_SetString(PyExc_ValueError, - "negative buffersize in recv"); + "negative buffersize in recv_into"); return NULL; } if (recvlen == 0) { @@ -2479,6 +2479,12 @@ sock_recvfrom(PySocketSockObject *s, PyObject *args) if (!PyArg_ParseTuple(args, "i|i:recvfrom", &recvlen, &flags)) return NULL; + if (recvlen < 0) { + PyErr_SetString(PyExc_ValueError, + "negative buffersize in recvfrom"); + return NULL; + } + buf = PyString_FromStringAndSize((char *) 0, recvlen); if (buf == NULL) return NULL; @@ -2525,14 +2531,15 @@ sock_recvfrom_into(PySocketSockObject *s, PyObject *args, PyObject* kwds) PyObject *addr = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "w#|ii:recvfrom", kwlist, - &buf, &buflen, &recvlen, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "w#|ii:recvfrom_into", + kwlist, &buf, &buflen, + &recvlen, &flags)) return NULL; assert(buf != 0 && buflen > 0); if (recvlen < 0) { PyErr_SetString(PyExc_ValueError, - "negative buffersize in recv"); + "negative buffersize in recvfrom_into"); return NULL; } if (recvlen == 0) { |