Skip to content

Commit

Permalink
QUIC CHANNEL: Only handle the first protocol error raised
Browse files Browse the repository at this point in the history
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #21715)
  • Loading branch information
hlandau committed Sep 1, 2023
1 parent 7841dba commit 549d0a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ssl/quic/quic_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -2930,6 +2930,10 @@ static void ch_start_terminating(QUIC_CHANNEL *ch,
const QUIC_TERMINATE_CAUSE *tcause,
int force_immediate)
{
/* No point sending anything if we haven't sent anything yet. */
if (!ch->have_sent_any_pkt)
force_immediate = 1;

switch (ch->state) {
default:
case QUIC_CHANNEL_STATE_IDLE:
Expand Down Expand Up @@ -3250,6 +3254,10 @@ void ossl_quic_channel_raise_protocol_error_loc(QUIC_CHANNEL *ch,
const char *ft_str = NULL;
const char *ft_str_pfx = " (", *ft_str_sfx = ")";

if (ch->protocol_error)
/* Only the first call to this function matters. */
return;

if (err_str == NULL) {
err_str = "";
err_str_pfx = "";
Expand Down Expand Up @@ -3297,6 +3305,7 @@ void ossl_quic_channel_raise_protocol_error_loc(QUIC_CHANNEL *ch,
tcause.reason = reason;
tcause.reason_len = strlen(reason);

ch->protocol_error = 1;
ch_start_terminating(ch, &tcause, 0);
}

Expand Down
8 changes: 8 additions & 0 deletions ssl/quic/quic_channel_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,14 @@ struct quic_channel_st {
/* Permanent net error encountered */
unsigned int net_error : 1;

/*
* Protocol error encountered. Note that you should refer to the state field
* rather than this. This is only used so we can ignore protocol errors
* after the first protocol error, but still record the first protocol error
* if it happens during the TERMINATING state.
*/
unsigned int protocol_error : 1;

/* Inhibit tick for testing purposes? */
unsigned int inhibit_tick : 1;

Expand Down

0 comments on commit 549d0a7

Please sign in to comment.