diff Modules/socketmodule.c @ 81590:d544873d62e9 2.7

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.
author Serhiy Storchaka <storchaka@gmail.com>
date Sat, 19 Jan 2013 12:55:39 +0200
parents 39803c20c9bf
children 8ec39bfd1f01
line wrap: on
line diff
--- a/Modules/socketmodule.c	Fri Jan 18 23:23:11 2013 -0800
+++ b/Modules/socketmodule.c	Sat Jan 19 12:55:39 2013 +0200
@@ -1713,7 +1713,7 @@
 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 @@
     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 @@
     int how;
     int res;
 
-    how = PyInt_AsLong(arg);
+    how = _PyInt_AsInt(arg);
     if (how == -1 && PyErr_Occurred())
         return NULL;
     Py_BEGIN_ALLOW_THREADS