From: Hugo Landau Date: Thu, 15 Dec 2022 07:07:12 +0000 (+0000) Subject: QUIC RXDP: Different error messages for stream conditions X-Git-Tag: openssl-3.2.0-alpha1~1471 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d2fd151d4e699da269e586713e785a758f45157;p=thirdparty%2Fopenssl.git QUIC RXDP: Different error messages for stream conditions Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/19703) --- diff --git a/ssl/quic/quic_rx_depack.c b/ssl/quic/quic_rx_depack.c index da941dc1039..e46e21bab42 100644 --- a/ssl/quic/quic_rx_depack.c +++ b/ssl/quic/quic_rx_depack.c @@ -111,11 +111,20 @@ static int depack_do_frame_reset_stream(PACKET *pkt, ackm_data->is_ack_eliciting = 1; stream = ossl_quic_stream_map_get_by_id(&ch->qsm, frame_data.stream_id); - if (stream == NULL || stream->rstream == NULL) { + if (stream == NULL) { ossl_quic_channel_raise_protocol_error(ch, QUIC_ERR_STREAM_STATE_ERROR, OSSL_QUIC_FRAME_TYPE_RESET_STREAM, - "RESET_STREAM frame for nonexistent or " + "RESET_STREAM frame for " + "nonexistent stream"); + return 0; + } + + if (stream->rstream == NULL) { + ossl_quic_channel_raise_protocol_error(ch, + QUIC_ERR_STREAM_STATE_ERROR, + OSSL_QUIC_FRAME_TYPE_RESET_STREAM, + "RESET_STREAM frame for " "TX only stream"); return 0; } @@ -144,11 +153,20 @@ static int depack_do_frame_stop_sending(PACKET *pkt, ackm_data->is_ack_eliciting = 1; stream = ossl_quic_stream_map_get_by_id(&ch->qsm, frame_data.stream_id); - if (stream == NULL || stream->sstream == NULL) { + if (stream == NULL) { + ossl_quic_channel_raise_protocol_error(ch, + QUIC_ERR_STREAM_STATE_ERROR, + OSSL_QUIC_FRAME_TYPE_STOP_SENDING, + "STOP_SENDING frame for " + "nonexistent stream"); + return 0; + } + + if (stream->sstream == NULL) { ossl_quic_channel_raise_protocol_error(ch, QUIC_ERR_STREAM_STATE_ERROR, OSSL_QUIC_FRAME_TYPE_STOP_SENDING, - "STOP_SENDING frame for nonexistent or " + "STOP_SENDING frame for " "RX only stream"); return 0; } @@ -235,12 +253,21 @@ static int depack_do_frame_stream(PACKET *pkt, QUIC_CHANNEL *ch, ackm_data->is_ack_eliciting = 1; stream = ossl_quic_stream_map_get_by_id(&ch->qsm, frame_data.stream_id); - if (stream == NULL || stream->rstream == NULL) { + if (stream == NULL) { ossl_quic_channel_raise_protocol_error(ch, QUIC_ERR_STREAM_STATE_ERROR, frame_type, - "STREAM frame for nonexistent or" - " TX only stream"); + "STREAM frame for nonexistent " + "stream"); + return 0; + } + + if (stream->rstream == NULL) { + ossl_quic_channel_raise_protocol_error(ch, + QUIC_ERR_STREAM_STATE_ERROR, + frame_type, + "STREAM frame for TX only " + "stream"); return 0; } @@ -323,12 +350,21 @@ static int depack_do_frame_max_stream_data(PACKET *pkt, ackm_data->is_ack_eliciting = 1; stream = ossl_quic_stream_map_get_by_id(&ch->qsm, stream_id); - if (stream == NULL || stream->sstream == NULL) { + if (stream == NULL) { + ossl_quic_channel_raise_protocol_error(ch, + QUIC_ERR_STREAM_STATE_ERROR, + OSSL_QUIC_FRAME_TYPE_MAX_STREAM_DATA, + "MAX_STREAM_DATA for nonexistent " + "stream"); + return 0; + } + + if (stream->sstream == NULL) { ossl_quic_channel_raise_protocol_error(ch, QUIC_ERR_STREAM_STATE_ERROR, OSSL_QUIC_FRAME_TYPE_MAX_STREAM_DATA, - "MAX_STREAM_DATA for nonexistent" - " or TX only stream"); + "MAX_STREAM_DATA for TX only " + "stream"); return 0; }