mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 11:49:12 +00:00 
			
		
		
		
	Safely downcast SOCKET_T to int in _ssl module
This commit is contained in:
		
							parent
							
								
									cc6cdce750
								
							
						
					
					
						commit
						b08ff7dcb4
					
				
					 1 changed files with 5 additions and 3 deletions
				
			
		| 
						 | 
					@ -499,7 +499,7 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
 | 
				
			||||||
    self->ssl = SSL_new(ctx);
 | 
					    self->ssl = SSL_new(ctx);
 | 
				
			||||||
    PySSL_END_ALLOW_THREADS
 | 
					    PySSL_END_ALLOW_THREADS
 | 
				
			||||||
    SSL_set_app_data(self->ssl,self);
 | 
					    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;
 | 
					    mode = SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER;
 | 
				
			||||||
#ifdef SSL_MODE_AUTO_RETRY
 | 
					#ifdef SSL_MODE_AUTO_RETRY
 | 
				
			||||||
    mode |= 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 */
 | 
					    /* See if the socket is ready */
 | 
				
			||||||
    PySSL_BEGIN_ALLOW_THREADS
 | 
					    PySSL_BEGIN_ALLOW_THREADS
 | 
				
			||||||
    if (writing)
 | 
					    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
 | 
					    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
 | 
					    PySSL_END_ALLOW_THREADS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_POLL
 | 
					#ifdef HAVE_POLL
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue