From: Remi Gacogne Date: Mon, 13 Oct 2025 14:13:03 +0000 (+0200) Subject: ComboAddress: Fix "unspecified address" test when the port is set X-Git-Tag: rec-5.4.0-alpha1~200^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=940d35a6237ba997bce1e1ef80ad836ad11da4ae;p=thirdparty%2Fpdns.git ComboAddress: Fix "unspecified address" test when the port is set This fixes the QUIC issue reported on FreeBSD: the frontend was not considered to be bound to an `ANY`/unspecified address because the port was set, causing the address selection address to fail. Signed-off-by: Remi Gacogne --- diff --git a/pdns/iputils.hh b/pdns/iputils.hh index d7b3ab9aec..c567f78950 100644 --- a/pdns/iputils.hh +++ b/pdns/iputils.hh @@ -286,9 +286,10 @@ union ComboAddress [[nodiscard]] bool isUnspecified() const { + const auto compare = ComboAddress::addressOnlyEqual(); const ComboAddress unspecifiedV4("0.0.0.0:0"); const ComboAddress unspecifiedV6("[::]:0"); - return *this == unspecifiedV4 || *this == unspecifiedV6; + return compare(*this, unspecifiedV4) || compare(*this, unspecifiedV6); } [[nodiscard]] ComboAddress mapToIPv4() const diff --git a/pdns/test-iputils_hh.cc b/pdns/test-iputils_hh.cc index 5d48c74134..975f289b2e 100644 --- a/pdns/test-iputils_hh.cc +++ b/pdns/test-iputils_hh.cc @@ -944,4 +944,26 @@ BOOST_AUTO_TEST_CASE(test_parseIPAndPort) } } +BOOST_AUTO_TEST_CASE(test_unspecified) +{ + struct { + std::string str; + bool unspecified; + } tests[] = { + { "0.0.0.0:0", true }, + { "[::]:0", true }, + { "0.0.0.0:853", true }, + { "[::]:853", true }, + { "192.0.2.1:0", false }, + { "192.0.2.1:853", false }, + { "[2001:db8::1]:0", false }, + { "[2001:db8::1]:853", false }, + }; + + for (const auto& test : tests) { + const ComboAddress address(test.str); + BOOST_CHECK_EQUAL(address.isUnspecified(), test.unspecified); + } +} + BOOST_AUTO_TEST_SUITE_END()