[PATCH 1 of 3] QUIC: fixed addr_text after migration (ticket #2488)

Roman Arutyunyan arut at nginx.com
Tue May 2 12:34:13 UTC 2023


# HG changeset patch
# User Roman Arutyunyan <arut at nginx.com>
# Date 1682610760 -14400
#      Thu Apr 27 19:52:40 2023 +0400
# Branch quic
# Node ID 746a3a71e428796b0593d098fcd299b94cc00108
# Parent  8347620e0e762c5dea99247dc70fbbffd0c6b175
QUIC: fixed addr_text after migration (ticket #2488).

Previously, the post-migration value of addr_text could be truncated, if
it was longer than the previous one.  Also, the new value always included
port, which should not be there.

diff --git a/src/event/quic/ngx_event_quic_migration.c b/src/event/quic/ngx_event_quic_migration.c
--- a/src/event/quic/ngx_event_quic_migration.c
+++ b/src/event/quic/ngx_event_quic_migration.c
@@ -384,16 +384,13 @@ ngx_quic_free_path(ngx_connection_t *c, 
 static void
 ngx_quic_set_connection_path(ngx_connection_t *c, ngx_quic_path_t *path)
 {
-    size_t  len;
-
     ngx_memcpy(c->sockaddr, path->sockaddr, path->socklen);
     c->socklen = path->socklen;
 
     if (c->addr_text.data) {
-        len = ngx_min(c->addr_text.len, path->addr_text.len);
-
-        ngx_memcpy(c->addr_text.data, path->addr_text.data, len);
-        c->addr_text.len = len;
+        c->addr_text.len = ngx_sock_ntop(c->sockaddr, c->socklen,
+                                         c->addr_text.data,
+                                         c->listening->addr_text_max_len, 0);
     }
 
     ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,


More information about the nginx-devel mailing list