apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mihai Limbasan <mihai...@gmail.com>
Subject Re: [BUG] Improper retval check on Win32 setsockopt() in sockopt.c
Date Sat, 25 Dec 2004 21:38:51 GMT
Ah, my bad, didn't notice -1 == SOCKET_ERROR. Still, it might be a
good idea to replace the == -1 with an == SOCKET_ERROR, if only to
avoid annoying people like me mailing :) Also, it's the canonical way.


On Sat, 25 Dec 2004 23:32:13 +0200, Mihai Limbasan <mihailim@gmail.com> wrote:
> 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.
> 


-- 
/earth is 98% full, please delete anyone you can

Mime
View raw message