The socket timeout is adjusted before reading and reset afterwards, in case a handshake is in progress to handle handshake timeouts properly. The reset, however, is done before the socket error handling. The new system call overwrites the error code when using Windows and breaks the error handling. Doing the error handling first fixes this issue.
Thanks to Nilesh Vaghela for providing hints!
Best regards
Robin
--- crypto/bio/bss_dgram.c 3 Jan 2011 01:07:03 -0000 1.7.2.24
+++ crypto/bio/bss_dgram.c 12 Jul 2011 11:20:23 -0000
@@ -308,7 +308,6 @@
OPENSSL_assert(sa.len.s<=sizeof(sa.peer));
sa.len.i = (int)sa.len.s;
}
- dgram_reset_rcv_timeout(b);
if ( ! data->connected && ret >= 0)
BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer);
@@ -322,6 +321,8 @@
data->_errno = get_last_socket_error();
}
}
+
+ dgram_reset_rcv_timeout(b);
}
return(ret);
}
@@ -745,9 +746,13 @@
{
err=get_last_socket_error();
-#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps
not? Ben 4/1/99 */
- if ((i == -1) && (err == 0))
- return(1);
+#if defined(OPENSSL_SYS_WINDOWS)
+ /* If the socket return value (i) is -1
+ * and err is unexpectedly 0 at this point,
+ * the error code was overwritten by
+ * another system call before this error
+ * handling is called.
+ */
#endif
return(BIO_dgram_non_fatal_error(err));
dtls-socket-error-bug-0.9.8.patch
Description: Binary data
dtls-socket-error-bug-1.0.0.patch
Description: Binary data
dtls-socket-error-bug-1.0.1.patch
Description: Binary data
