[Python-checkins] cpython: Issue #22042: Avoid dangerous C cast in socket.setblocking()
victor.stinner
python-checkins at python.org
Wed Jul 23 23:00:07 CEST 2014
http://hg.python.org/cpython/rev/9dc66b3a1d0d
changeset: 91803:9dc66b3a1d0d
user: Victor Stinner <victor.stinner at gmail.com>
date: Wed Jul 23 22:56:55 2014 +0200
summary:
Issue #22042: Avoid dangerous C cast in socket.setblocking()
Avoid cast from (int*) to (u_long*), even if sizeof(int) == sizeof(u_long).
files:
Modules/socketmodule.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -548,6 +548,9 @@
static int
internal_setblocking(PySocketSockObject *s, int block)
{
+#ifdef MS_WINDOWS
+ u_long arg;
+#endif
#if !defined(MS_WINDOWS) \
&& !((defined(HAVE_SYS_IOCTL_H) && defined(FIONBIO)))
int delay_flag, new_delay_flag;
@@ -574,8 +577,8 @@
fcntl(s->sock_fd, F_SETFL, new_delay_flag);
#endif
#else /* MS_WINDOWS */
- block = !block;
- ioctlsocket(s->sock_fd, FIONBIO, (u_long*)&block);
+ arg = !block;
+ ioctlsocket(s->sock_fd, FIONBIO, &arg);
#endif /* MS_WINDOWS */
Py_END_ALLOW_THREADS
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list