From df92d387c0e6bd4ff598277a93a25c626087fdbd Mon Sep 17 00:00:00 2001 From: Rene Meusel Date: Fri, 22 Dec 2023 11:02:02 +0100 Subject: [PATCH] Work around a warning in GCC 13 ... which claims that the replaced code creates a 'possibly dangling reference'. I'm quite sure that this warning is a false positive but let's be safe. --- src/cli/tls_utils.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cli/tls_utils.cpp b/src/cli/tls_utils.cpp index f4845268c84..2703c800f0b 100644 --- a/src/cli/tls_utils.cpp +++ b/src/cli/tls_utils.cpp @@ -123,8 +123,8 @@ class TLS_Client_Hello_Reader final : public Command { const std::variant& hello) { std::ostringstream oss; - const auto& hello_base = - std::visit([](const auto& ch) -> const Botan::TLS::Client_Hello& { return ch; }, hello); + const auto* hello_base = + std::visit([](const auto& ch) -> const Botan::TLS::Client_Hello* { return &ch; }, hello); const auto version = std::visit(Botan::overloaded{ [](const Botan::TLS::Client_Hello_12&) { return "1.2"; }, @@ -133,12 +133,12 @@ class TLS_Client_Hello_Reader final : public Command { hello); oss << "Version: " << version << "\n" - << "Random: " << Botan::hex_encode(hello_base.random()) << "\n"; + << "Random: " << Botan::hex_encode(hello_base->random()) << "\n"; - if(!hello_base.session_id().empty()) { - oss << "SessionID: " << Botan::hex_encode(hello_base.session_id().get()) << "\n"; + if(!hello_base->session_id().empty()) { + oss << "SessionID: " << Botan::hex_encode(hello_base->session_id().get()) << "\n"; } - for(uint16_t csuite_id : hello_base.ciphersuites()) { + for(uint16_t csuite_id : hello_base->ciphersuites()) { const auto csuite = Botan::TLS::Ciphersuite::by_id(csuite_id); if(csuite && csuite->valid()) { oss << "Cipher: " << csuite->to_string() << "\n"; @@ -151,10 +151,10 @@ class TLS_Client_Hello_Reader final : public Command { oss << "Supported signature schemes: "; - if(hello_base.signature_schemes().empty()) { + if(hello_base->signature_schemes().empty()) { oss << "Did not send signature_algorithms extension\n"; } else { - for(Botan::TLS::Signature_Scheme scheme : hello_base.signature_schemes()) { + for(Botan::TLS::Signature_Scheme scheme : hello_base->signature_schemes()) { try { auto s = scheme.to_string(); oss << s << " "; @@ -165,7 +165,7 @@ class TLS_Client_Hello_Reader final : public Command { oss << "\n"; } - if(auto sg = hello_base.extensions().get()) { + if(auto sg = hello_base->extensions().get()) { oss << "Supported Groups: "; for(const auto group : sg->groups()) { oss << group.to_string().value_or(Botan::fmt("Unknown group: {}", group.wire_code())) << " "; @@ -174,7 +174,7 @@ class TLS_Client_Hello_Reader final : public Command { } std::map hello_flags; - hello_flags["ALPN"] = hello_base.supports_alpn(); + hello_flags["ALPN"] = hello_base->supports_alpn(); std::visit(Botan::overloaded{ [&](const Botan::TLS::Client_Hello_12& ch12) {