Issue #15989: Fix several occurrences of integer overflow

when result of PyInt_AsLong() or PyLong_AsLong() narrowed
to int without checks.

This is a backport of changesets 13e2e44db99d and 525407d89277.
This commit is contained in:
Serhiy Storchaka 2013-01-19 12:55:39 +02:00
parent ac7b49f407
commit 74f49ab28b
17 changed files with 143 additions and 22 deletions

View file

@ -1713,7 +1713,7 @@ info is a pair (hostaddr, port).");
static PyObject *
sock_setblocking(PySocketSockObject *s, PyObject *arg)
{
int block;
long block;
block = PyInt_AsLong(arg);
if (block == -1 && PyErr_Occurred())
@ -2243,7 +2243,7 @@ sock_listen(PySocketSockObject *s, PyObject *arg)
int backlog;
int res;
backlog = PyInt_AsLong(arg);
backlog = _PyInt_AsInt(arg);
if (backlog == -1 && PyErr_Occurred())
return NULL;
Py_BEGIN_ALLOW_THREADS
@ -2894,7 +2894,7 @@ sock_shutdown(PySocketSockObject *s, PyObject *arg)
int how;
int res;
how = PyInt_AsLong(arg);
how = _PyInt_AsInt(arg);
if (how == -1 && PyErr_Occurred())
return NULL;
Py_BEGIN_ALLOW_THREADS