From 5514a27a59a4d06ba3fc0f9706a0c571fbd7bb37 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Mon, 17 Apr 2023 19:36:23 -0400 Subject: [PATCH] fix bad_variant_access resulting from ConvoTag->AddressVariant change We changed the quic code to refer to its remote endpoint using an Address Variant and this resulted in a crash when sending a connection close packet. This code was incorrectly supplying an uninitialized value for ConvoTag before but this was silently ignored; after switching to a variant it became a crash. --- llarp/quic/endpoint.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/llarp/quic/endpoint.cpp b/llarp/quic/endpoint.cpp index 4b27381ed..f96563af9 100644 --- a/llarp/quic/endpoint.cpp +++ b/llarp/quic/endpoint.cpp @@ -295,11 +295,10 @@ namespace llarp::quic close_reason.size()); conn.conn_buffer.resize(max_pkt_size_v4); - Path path; ngtcp2_pkt_info pi; auto written = ngtcp2_conn_write_connection_close( - conn, path, &pi, u8data(conn.conn_buffer), conn.conn_buffer.size(), &err, get_timestamp()); + conn, &conn.path.path, &pi, u8data(conn.conn_buffer), conn.conn_buffer.size(), &err, get_timestamp()); if (written <= 0) { log::warning( @@ -314,8 +313,6 @@ namespace llarp::quic conn.conn_buffer.resize(written); conn.closing = true; - conn.path = path; - assert(conn.closing && !conn.conn_buffer.empty()); if (auto sent = send_packet(conn.path.remote, conn.conn_buffer, 0); not sent) @@ -411,6 +408,7 @@ namespace llarp::quic conns.erase(it); if (primary) clean_alias_conns(); + return true; }