[Python-checkins] cpython: Safely downcast SOCKET_T to int in _ssl module

christian.heimes python-checkins at python.org
Mon Nov 18 10:04:18 CET 2013


http://hg.python.org/cpython/rev/00348c0518f8
changeset:   87241:00348c0518f8
user:        Christian Heimes <christian at cheimes.de>
date:        Mon Nov 18 10:04:07 2013 +0100
summary:
  Safely downcast SOCKET_T to int in _ssl module

files:
  Modules/_ssl.c |  8 +++++---
  1 files changed, 5 insertions(+), 3 deletions(-)


diff --git a/Modules/_ssl.c b/Modules/_ssl.c
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -499,7 +499,7 @@
     self->ssl = SSL_new(ctx);
     PySSL_END_ALLOW_THREADS
     SSL_set_app_data(self->ssl,self);
-    SSL_set_fd(self->ssl, sock->sock_fd);
+    SSL_set_fd(self->ssl, Py_SAFE_DOWNCAST(sock->sock_fd, SOCKET_T, int));
     mode = SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER;
 #ifdef SSL_MODE_AUTO_RETRY
     mode |= SSL_MODE_AUTO_RETRY;
@@ -1378,9 +1378,11 @@
     /* See if the socket is ready */
     PySSL_BEGIN_ALLOW_THREADS
     if (writing)
-        rc = select(s->sock_fd+1, NULL, &fds, NULL, &tv);
+        rc = select(Py_SAFE_DOWNCAST(s->sock_fd+1, SOCKET_T, int),
+                    NULL, &fds, NULL, &tv);
     else
-        rc = select(s->sock_fd+1, &fds, NULL, NULL, &tv);
+        rc = select(Py_SAFE_DOWNCAST(s->sock_fd+1, SOCKET_T, int),
+                    &fds, NULL, NULL, &tv);
     PySSL_END_ALLOW_THREADS
 
 #ifdef HAVE_POLL

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list