apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mihai Limbasan <mihai...@gmail.com>
Subject [BUG] Improper retval check on Win32 setsockopt() in sockopt.c
Date Sat, 25 Dec 2004 21:32:13 GMT
apr_socket_opt_set() in network_io/win32/sockopt.c invokes
setsockopt() a few times, a la

if (setsockopt(sock->socketdes, SOL_SOCKET, SO_KEEPALIVE, (void
*)&one, sizeof(int)) == -1) {
    return apr_get_netos_error();

While that works just fine on Unix (retval -1 indicates error and
requires subsequent checking of errno), it's incorrect on Win32. The
WinSock2 section of the Platform SDK states that setsockopt() returns
zero if no error occurs and returns one of the WSA* constants if one
does occur.
The proper way of checking the setsockopt() retval in above code would
be to check for inequality to zero instead of equality to -1.
This file seems to be the only one affected.

View raw message