From: Matt Caswell Date: Thu, 3 May 2018 14:59:31 +0000 (+0100) Subject: Fix s_client and s_server so that they correctly handle the DTLS timer X-Git-Tag: OpenSSL_1_1_0i~123 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=960e7bfb32af0ff3586ae2b4953d1228fa43ea16;p=oweals%2Fopenssl.git Fix s_client and s_server so that they correctly handle the DTLS timer Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/6196) --- diff --git a/apps/s_client.c b/apps/s_client.c index 81669d0401..3c0c73e851 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -2115,8 +2115,7 @@ int s_client_main(int argc, char **argv) FD_ZERO(&readfds); FD_ZERO(&writefds); - if ((SSL_version(con) == DTLS1_VERSION) && - DTLSv1_get_timeout(con, &timeout)) + if (SSL_is_dtls(con) && DTLSv1_get_timeout(con, &timeout)) timeoutp = &timeout; else timeoutp = NULL; @@ -2236,10 +2235,8 @@ int s_client_main(int argc, char **argv) } } - if ((SSL_version(con) == DTLS1_VERSION) - && DTLSv1_handle_timeout(con) > 0) { + if (SSL_is_dtls(con) && DTLSv1_handle_timeout(con) > 0) BIO_printf(bio_err, "TIMEOUT occurred\n"); - } if (!ssl_pending && FD_ISSET(SSL_get_fd(con), &writefds)) { k = SSL_write(con, &(cbuf[cbuf_off]), (unsigned int)cbuf_len); diff --git a/apps/s_server.c b/apps/s_server.c index 96a74c441d..e8aa323a4f 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -2155,18 +2155,15 @@ static int sv_body(int s, int stype, unsigned char *context) if ((i < 0) || (!i && !read_from_terminal)) continue; #else - if ((SSL_version(con) == DTLS1_VERSION) && - DTLSv1_get_timeout(con, &timeout)) + if (SSL_is_dtls(con) && DTLSv1_get_timeout(con, &timeout)) timeoutp = &timeout; else timeoutp = NULL; i = select(width, (void *)&readfds, NULL, NULL, timeoutp); - if ((SSL_version(con) == DTLS1_VERSION) - && DTLSv1_handle_timeout(con) > 0) { + if ((SSL_is_dtls(con)) && DTLSv1_handle_timeout(con) > 0) BIO_printf(bio_err, "TIMEOUT occurred\n"); - } if (i <= 0) continue;