diff options
author | Facundo Batista <facundobatista@gmail.com> | 2007-03-28 03:45:20 (GMT) |
---|---|---|
committer | Facundo Batista <facundobatista@gmail.com> | 2007-03-28 03:45:20 (GMT) |
commit | 1fe9f968a21843175c3cbd6adf632aa95d2f2bef (patch) | |
tree | 85658d73283cf4945e086b3b43224265667908c9 /Modules/socketmodule.c | |
parent | b20c500251949028d38b32112e864da3cd074be0 (diff) | |
download | cpython-1fe9f968a21843175c3cbd6adf632aa95d2f2bef.zip cpython-1fe9f968a21843175c3cbd6adf632aa95d2f2bef.tar.gz cpython-1fe9f968a21843175c3cbd6adf632aa95d2f2bef.tar.bz2 |
Bug 1688393. Adds a control of negative values in
socket.recvfrom, which caused an ugly crash.
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index cc54098..96682ca 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2391,7 +2391,7 @@ sock_recv_into(PySocketSockObject *s, PyObject *args, PyObject *kwds) if (recvlen < 0) { PyErr_SetString(PyExc_ValueError, - "negative buffersize in recv"); + "negative buffersize in recv_into"); return NULL; } if (recvlen == 0) { @@ -2507,6 +2507,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; @@ -2560,7 +2566,7 @@ sock_recvfrom_into(PySocketSockObject *s, PyObject *args, PyObject* kwds) if (recvlen < 0) { PyErr_SetString(PyExc_ValueError, - "negative buffersize in recv"); + "negative buffersize in recvfrom_into"); return NULL; } if (recvlen == 0) { |