From cfbe41ea9138ba5f4fb6f859a72034ba4ddc693f Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Wed, 17 Jun 2020 11:34:49 +0100 Subject: [PATCH 1/1] Fix the DTLS1_COOKIE_LENGTH value The DTLS1_COOKIE_LENGTH value was incorrect in the header files. We couldn't change it before due to ABI concerns. However 3.0 is not ABI compatible so we can now fix it. Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/12179) --- include/openssl/dtls1.h | 7 ++----- ssl/statem/statem_srvr.c | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/openssl/dtls1.h b/include/openssl/dtls1.h index bfc2d6e38f..a68cffd1d4 100644 --- a/include/openssl/dtls1.h +++ b/include/openssl/dtls1.h @@ -36,11 +36,8 @@ extern "C" { # define DTLS_ANY_VERSION 0x1FFFF /* lengths of messages */ -/* - * Actually the max cookie length in DTLS is 255. But we can't change this now - * due to compatibility concerns. - */ -# define DTLS1_COOKIE_LENGTH 256 + +# define DTLS1_COOKIE_LENGTH 255 # define DTLS1_RT_HEADER_LENGTH 13 diff --git a/ssl/statem/statem_srvr.c b/ssl/statem/statem_srvr.c index d3913e1b7d..abffbd6326 100644 --- a/ssl/statem/statem_srvr.c +++ b/ssl/statem/statem_srvr.c @@ -1312,7 +1312,7 @@ int dtls_construct_hello_verify_request(SSL *s, WPACKET *pkt) if (s->ctx->app_gen_cookie_cb == NULL || s->ctx->app_gen_cookie_cb(s, s->d1->cookie, &cookie_leni) == 0 || - cookie_leni > 255) { + cookie_leni > DTLS1_COOKIE_LENGTH) { SSLfatal(s, SSL_AD_NO_ALERT, SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST, SSL_R_COOKIE_GEN_CALLBACK_FAILURE); return 0; -- 2.34.1