]> git.kaiwu.me - nginx.git/commitdiff
QUIC: reallocate qc->dcid on retry.
authorRoman Arutyunyan <arut@nginx.com>
Wed, 11 Nov 2020 17:56:02 +0000 (17:56 +0000)
committerRoman Arutyunyan <arut@nginx.com>
Wed, 11 Nov 2020 17:56:02 +0000 (17:56 +0000)
Previously new dcid was generated in the same memory that was allocated for
qc->dcid when creating the QUIC connection.  However this memory was also
referenced by initial_source_connection_id and retry_source_connection_id
transport parameters.  As a result these parameters changed their values after
retry which broke the protocol.

src/event/ngx_event_quic.c

index 7643cecfb0ca217fe2632d86b18c6be280a72fb3..099f8778ec08528a11b53eb619c3994b703a872e 100644 (file)
@@ -2158,6 +2158,12 @@ ngx_quic_process_packet(ngx_connection_t *c, ngx_quic_conf_t *conf,
 
             ngx_quic_clear_temp_server_ids(c);
 
+            qc->dcid.len = NGX_QUIC_SERVER_CID_LEN;
+            qc->dcid.data = ngx_pnalloc(c->pool, qc->dcid.len);
+            if (qc->dcid.data == NULL) {
+                return NGX_ERROR;
+            }
+
             if (ngx_quic_create_server_id(c, qc->dcid.data) != NGX_OK) {
                 return NGX_ERROR;
             }