mirror of
https://github.com/python/cpython.git
synced 2025-11-11 14:44:57 +00:00
Issue #22042: Avoid dangerous C cast in socket.setblocking()
Avoid cast from (int*) to (u_long*), even if sizeof(int) == sizeof(u_long).
This commit is contained in:
parent
baddc840d5
commit
b6dab6bce8
1 changed files with 5 additions and 2 deletions
|
|
@ -548,6 +548,9 @@ set_gaierror(int error)
|
||||||
static int
|
static int
|
||||||
internal_setblocking(PySocketSockObject *s, int block)
|
internal_setblocking(PySocketSockObject *s, int block)
|
||||||
{
|
{
|
||||||
|
#ifdef MS_WINDOWS
|
||||||
|
u_long arg;
|
||||||
|
#endif
|
||||||
#if !defined(MS_WINDOWS) \
|
#if !defined(MS_WINDOWS) \
|
||||||
&& !((defined(HAVE_SYS_IOCTL_H) && defined(FIONBIO)))
|
&& !((defined(HAVE_SYS_IOCTL_H) && defined(FIONBIO)))
|
||||||
int delay_flag, new_delay_flag;
|
int delay_flag, new_delay_flag;
|
||||||
|
|
@ -574,8 +577,8 @@ internal_setblocking(PySocketSockObject *s, int block)
|
||||||
fcntl(s->sock_fd, F_SETFL, new_delay_flag);
|
fcntl(s->sock_fd, F_SETFL, new_delay_flag);
|
||||||
#endif
|
#endif
|
||||||
#else /* MS_WINDOWS */
|
#else /* MS_WINDOWS */
|
||||||
block = !block;
|
arg = !block;
|
||||||
ioctlsocket(s->sock_fd, FIONBIO, (u_long*)&block);
|
ioctlsocket(s->sock_fd, FIONBIO, &arg);
|
||||||
#endif /* MS_WINDOWS */
|
#endif /* MS_WINDOWS */
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue