From 8a7cf2543ac9c06787cb191cdfb20d54e1e49ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 9 Oct 2014 17:35:53 +0200 Subject: [PATCH] Add a few #ifdefs --- library/ssl_srv.c | 7 +++++-- library/ssl_tls.c | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 3cd87f92c..32f107282 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -1182,8 +1182,11 @@ read_record_header: buf = ssl->in_hdr; #if defined(POLARSSL_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO) - if( ssl->transport == SSL_TRANSPORT_STREAM && ( buf[0] & 0x80 ) != 0 ) - return ssl_parse_client_hello_v2( ssl ); +#if defined(POLARSSL_SSL_PROTO_DTLS) + if( ssl->transport == SSL_TRANSPORT_STREAM ) +#endif + if( ( buf[0] & 0x80 ) != 0 ) + return ssl_parse_client_hello_v2( ssl ); #endif SSL_DEBUG_BUF( 4, "record header", buf, ssl_hdr_len( ssl ) ); diff --git a/library/ssl_tls.c b/library/ssl_tls.c index fecce58c6..de85b676c 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5302,13 +5302,21 @@ const char *ssl_get_alpn_protocol( const ssl_context *ssl ) static int ssl_check_version( const ssl_context *ssl, int major, int minor ) { if( major < SSL_MIN_MAJOR_VERSION || major > SSL_MAX_MAJOR_VERSION || - minor < SSL_MIN_MINOR_VERSION || minor > SSL_MAX_MINOR_VERSION || - ( ssl->transport == SSL_TRANSPORT_DATAGRAM && - minor < SSL_MINOR_VERSION_2 ) ) + minor < SSL_MIN_MINOR_VERSION || minor > SSL_MAX_MINOR_VERSION ) { return( -1 ); } +#if defined(POLARSSL_SSL_PROTO_DTLS) + if( ssl->transport == SSL_TRANSPORT_DATAGRAM && + minor < SSL_MINOR_VERSION_2 ) + { + return( -1 ); + } +#else + ((void) ssl); +#endif + return( 0 ); } @@ -5788,8 +5796,8 @@ int ssl_read( ssl_context *ssl, unsigned char *buf, size_t len ) } else { -#if defined(POLARSSL_SSL_PROTO_DTLS) /* DTLS clients need to know renego is server-initiated */ +#if defined(POLARSSL_SSL_PROTO_DTLS) if( ssl->transport == SSL_TRANSPORT_DATAGRAM && ssl->endpoint == SSL_IS_CLIENT ) {