]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
ComboAddress: Fix "unspecified address" test when the port is set
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 13 Oct 2025 14:13:03 +0000 (16:13 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 13 Oct 2025 14:13:03 +0000 (16:13 +0200)
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 <remi.gacogne@powerdns.com>
pdns/iputils.hh
pdns/test-iputils_hh.cc

index d7b3ab9aecabeb6f50c24198eefa6d4ce56763fc..c567f789503086372b5b72a4937a015b78e44e23 100644 (file)
@@ -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
index 5d48c74134997180f16e09a8e8b599370fa72e3e..975f289b2edb29f88eda73e1b7012720846f8867 100644 (file)
@@ -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()