From 5d59cf9961453d28fa351b99acdaa9af22d9058b Mon Sep 17 00:00:00 2001 From: Todd Short Date: Mon, 26 Aug 2019 13:29:17 -0400 Subject: [PATCH] Fix quic_transport constructors/parsers --- ssl/statem/extensions_clnt.c | 17 +++-------------- ssl/statem/extensions_srvr.c | 17 +++-------------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/ssl/statem/extensions_clnt.c b/ssl/statem/extensions_clnt.c index de0ccfa2f93c1..4ad6bf47d66dd 100644 --- a/ssl/statem/extensions_clnt.c +++ b/ssl/statem/extensions_clnt.c @@ -1266,10 +1266,8 @@ EXT_RETURN tls_construct_ctos_quic_transport_params(SSL *s, WPACKET *pkt, } if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_quic_transport_parameters) - || !WPACKET_start_sub_packet_u16(pkt) - || !WPACKET_sub_memcpy_u16(pkt, s->ext.quic_transport_params, - s->ext.quic_transport_params_len) - || !WPACKET_close(pkt)) { + || !WPACKET_sub_memcpy_u16(pkt, s->ext.quic_transport_params, + s->ext.quic_transport_params_len)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CTOS_QUIC_TRANSPORT_PARAMS, ERR_R_INTERNAL_ERROR); return EXT_RETURN_FAIL; @@ -2069,20 +2067,11 @@ int tls_parse_stoc_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x, int tls_parse_stoc_quic_transport_params(SSL *s, PACKET *pkt, unsigned int context, X509 *x, size_t chainidx) { - PACKET trans_param; - - if (!PACKET_as_length_prefixed_2(pkt, &trans_param) - || PACKET_remaining(&trans_param) == 0) { - SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PARSE_STOC_QUIC_TRANSPORT_PARAMS, - SSL_R_BAD_EXTENSION); - return 0; - } - OPENSSL_free(s->ext.peer_quic_transport_params); s->ext.peer_quic_transport_params = NULL; s->ext.peer_quic_transport_params_len = 0; - if (!PACKET_memdup(&trans_param, + if (!PACKET_memdup(pkt, &s->ext.peer_quic_transport_params, &s->ext.peer_quic_transport_params_len)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, diff --git a/ssl/statem/extensions_srvr.c b/ssl/statem/extensions_srvr.c index 0f99517de1f63..8d449b96a4bf8 100644 --- a/ssl/statem/extensions_srvr.c +++ b/ssl/statem/extensions_srvr.c @@ -1306,20 +1306,11 @@ int tls_parse_ctos_post_handshake_auth(SSL *s, PACKET *pkt, unsigned int context int tls_parse_ctos_quic_transport_params(SSL *s, PACKET *pkt, unsigned int context, X509 *x, size_t chainidx) { - PACKET trans_param; - - if (!PACKET_as_length_prefixed_2(pkt, &trans_param) - || PACKET_remaining(&trans_param) == 0) { - SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PARSE_CTOS_QUIC_TRANSPORT_PARAMS, - SSL_R_BAD_EXTENSION); - return 0; - } - OPENSSL_free(s->ext.peer_quic_transport_params); s->ext.peer_quic_transport_params = NULL; s->ext.peer_quic_transport_params_len = 0; - if (!PACKET_memdup(&trans_param, + if (!PACKET_memdup(pkt, &s->ext.peer_quic_transport_params, &s->ext.peer_quic_transport_params_len)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, @@ -2003,10 +1994,8 @@ EXT_RETURN tls_construct_stoc_quic_transport_params(SSL *s, WPACKET *pkt, } if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_quic_transport_parameters) - || !WPACKET_start_sub_packet_u16(pkt) - || !WPACKET_sub_memcpy_u16(pkt, s->ext.quic_transport_params, - s->ext.quic_transport_params_len) - || !WPACKET_close(pkt)) { + || !WPACKET_sub_memcpy_u16(pkt, s->ext.quic_transport_params, + s->ext.quic_transport_params_len)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_STOC_QUIC_TRANSPORT_PARAMS, ERR_R_INTERNAL_ERROR); return EXT_RETURN_FAIL;