changeset 8631:e167c7b4cff4 quic

QUIC: reallocate qc->dcid on retry. 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.
author Roman Arutyunyan <arut@nginx.com>
date Wed, 11 Nov 2020 17:56:02 +0000
parents 279ad36f2f4b
children 50f5c4f75fc1
files src/event/ngx_event_quic.c
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/event/ngx_event_quic.c
+++ b/src/event/ngx_event_quic.c
@@ -2158,6 +2158,12 @@ ngx_quic_process_packet(ngx_connection_t
 
             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;
             }