Skip to content

Commit

Permalink
Fix overflow warning in dumb_socketpair() on Win64
Browse files Browse the repository at this point in the history
The SOCKET type is a pointer, although in practice what's returned really
does look like a file descriptor. It's a low-valued integer such as 0x23
under Wine, 0x54 under Windows 7 in my testing.

The INVALID_SOCKET error return from socket() is defined as (SOCKET)(~0),
or 0xFFFFFFFFFFFFFFFF on Win64. Thus we get errors when assigning it to
an int in the socks[] array. So use -1 here instead.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Feb 12, 2014
1 parent a21ec12 commit bdeefa5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compat.c
Expand Up @@ -295,7 +295,7 @@ int dumb_socketpair(int socks[2], int make_overlapped)
a.inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
a.inaddr.sin_port = 0;

socks[0] = socks[1] = INVALID_SOCKET;
socks[0] = socks[1] = -1;
do {
if (setsockopt(listener, SOL_SOCKET, SO_REUSEADDR,
(char*) &reuse, (socklen_t) sizeof(reuse)) == -1)
Expand Down

0 comments on commit bdeefa5

Please sign in to comment.