QUIC CHANNEL: Fix idle timeout handling
authorHugo Landau <hlandau@openssl.org>
Tue, 21 Feb 2023 10:18:59 +0000 (10:18 +0000)
committerHugo Landau <hlandau@openssl.org>
Thu, 30 Mar 2023 10:14:09 +0000 (11:14 +0100)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20348)

ssl/quic/quic_channel.c

index 2774329e5c615dc0c7551137754f8889f6db6463..8ffb5b99e404991def38fdd50063a4ce45b0db0f 100644 (file)
@@ -255,6 +255,13 @@ static int ch_init(QUIC_CHANNEL *ch)
     if ((ch->qtls = ossl_quic_tls_new(&tls_args)) == NULL)
         goto err;
 
+    ch->rx_max_ack_delay        = QUIC_DEFAULT_MAX_ACK_DELAY;
+    ch->rx_ack_delay_exp        = QUIC_DEFAULT_ACK_DELAY_EXP;
+    ch->rx_active_conn_id_limit = QUIC_MIN_ACTIVE_CONN_ID_LIMIT;
+    ch->max_idle_timeout        = QUIC_DEFAULT_IDLE_TIMEOUT;
+    ch->tx_enc_level            = QUIC_ENC_LEVEL_INITIAL;
+    ch->rx_enc_level            = QUIC_ENC_LEVEL_INITIAL;
+
     /*
      * Determine the QUIC Transport Parameters and serialize the transport
      * parameters block. (For servers, we do this later as we must defer
@@ -263,12 +270,6 @@ static int ch_init(QUIC_CHANNEL *ch)
     if (!ch->is_server && !ch_generate_transport_params(ch))
         goto err;
 
-    ch->rx_max_ack_delay        = QUIC_DEFAULT_MAX_ACK_DELAY;
-    ch->rx_ack_delay_exp        = QUIC_DEFAULT_ACK_DELAY_EXP;
-    ch->rx_active_conn_id_limit = QUIC_MIN_ACTIVE_CONN_ID_LIMIT;
-    ch->max_idle_timeout        = QUIC_DEFAULT_IDLE_TIMEOUT;
-    ch->tx_enc_level            = QUIC_ENC_LEVEL_INITIAL;
-    ch->rx_enc_level            = QUIC_ENC_LEVEL_INITIAL;
     ch_update_idle(ch);
     ossl_quic_reactor_init(&ch->rtor, ch_tick, ch,
                            ch_determine_next_tick_deadline(ch));
@@ -971,7 +972,7 @@ static int ch_on_transport_params(const unsigned char *params,
                 goto malformed;
             }
 
-            if (v < ch->max_idle_timeout)
+            if (v > 0 && v < ch->max_idle_timeout)
                 ch->max_idle_timeout = v;
 
             ch_update_idle(ch);