cpython: 9e10c4255277 (original) (raw)
Mercurial > cpython
changeset 94594:9e10c4255277
Issue #23450: Fix signal.set_wakeup_fd() on Windows Detect integer overflow on the file descriptor of the socket on 64-bit Python. [#23450]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Thu, 12 Feb 2015 16:34:54 +0100 |
parents | 4828cb77bf2a |
children | b8acfbf5aa61 |
files | Modules/signalmodule.c |
diffstat | 1 files changed, 14 insertions(+), 11 deletions(-)[+] [-] Modules/signalmodule.c 25 |
line wrap: on
line diff
--- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -505,7 +505,7 @@ signal_set_wakeup_fd(PyObject *self, PyO { #ifdef MS_WINDOWS PyObject *fdobj;
- SOCKET_T sockfd, old_sockfd; int res; int res_size = sizeof res; PyObject *mod; @@ -515,8 +515,8 @@ signal_set_wakeup_fd(PyObject *self, PyO if (!PyArg_ParseTuple(args, "O:set_wakeup_fd", &fdobj)) return NULL;
#else int fd, old_fd; @@ -536,7 +536,7 @@ signal_set_wakeup_fd(PyObject *self, PyO #ifdef MS_WINDOWS is_socket = 0;
- if (sockfd != INVALID_FD) { /* Import the _socket module to call WSAStartup() */ mod = PyImport_ImportModuleNoBlock("_socket"); if (mod == NULL)
@@ -544,15 +544,18 @@ signal_set_wakeup_fd(PyObject self, PyO Py_DECREF(mod); / test the socket */
if (getsockopt(fd, SOL_SOCKET, SO_ERROR,[](#l1.36)
if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR,[](#l1.37) (char *)&res, &res_size) != 0) {[](#l1.38)
int err = WSAGetLastError();[](#l1.39)
int fd, err;[](#l1.40)
err = WSAGetLastError();[](#l1.42) if (err != WSAENOTSOCK) {[](#l1.43) PyErr_SetExcFromWindowsErr(PyExc_OSError, err);[](#l1.44) return NULL;[](#l1.45) }[](#l1.46)
if (!_PyVerify_fd(fd)) {[](#l1.48)
fd = (int)sockfd;[](#l1.49)
if ((SOCKET_T)fd != sockfd || !_PyVerify_fd(fd)) {[](#l1.50) PyErr_SetString(PyExc_ValueError, "invalid fd");[](#l1.51) return NULL;[](#l1.52) }[](#l1.53)
@@ -572,12 +575,12 @@ signal_set_wakeup_fd(PyObject *self, PyO } }