summaryrefslogtreecommitdiffstats
path: root/Modules/_ssl.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-11-18 09:04:07 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-11-18 09:04:07 (GMT)
commitb08ff7dcb4725e9659e3234836ba5e60b191815e (patch)
tree5b455582f9aaae23b03fc6f3e18b9700b9160956 /Modules/_ssl.c
parentcc6cdce75095e99444492b2ed63e26c63c776128 (diff)
downloadcpython-b08ff7dcb4725e9659e3234836ba5e60b191815e.zip
cpython-b08ff7dcb4725e9659e3234836ba5e60b191815e.tar.gz
cpython-b08ff7dcb4725e9659e3234836ba5e60b191815e.tar.bz2
Safely downcast SOCKET_T to int in _ssl module
Diffstat (limited to 'Modules/_ssl.c')
-rw-r--r--Modules/_ssl.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 75b8360..933f66e 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -499,7 +499,7 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
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 @@ check_socket_and_wait_for_timeout(PySocketSockObject *s, int writing)
/* 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