]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsname: Add a comment about what `DNSName::matches` accepts
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 28 Jul 2025 09:29:40 +0000 (11:29 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 22 Aug 2025 13:12:33 +0000 (15:12 +0200)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
(cherry picked from commit 7394dd09afce13c1cd287c2b63f8d129e8be22af)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsname.hh
pdns/test-dnsname_cc.cc

index 8d7a9571e7c68c2f8cabae5a6b3112ca147f4345..b09a004b5c44c26343f869836de3ef29a42150e5 100644 (file)
@@ -112,7 +112,8 @@ public:
   bool isPartOf(const DNSName& rhs) const;   //!< Are we part of the rhs name? Note that name.isPartOf(name).
   inline bool operator==(const DNSName& rhs) const; //!< DNS-native comparison (case insensitive) - empty compares to empty
   bool operator!=(const DNSName& other) const { return !(*this == other); }
-  bool matches(const std::string_view& wire_uncompressed) const; // DNS-native (case insensitive) comparison against raw data in wire format
+  // !< DNS-native (case insensitive) comparison against raw data in wire format. The view has to start with the DNS name, but does not have to contain only a DNS name. For example passing a view of a DNS packet starting just after the DNS header is OK.
+  bool matches(const std::string_view& wire_uncompressed) const;
 
   std::string toString(const std::string& separator=".", const bool trailing=true) const;              //!< Our human-friendly, escaped, representation
   void toString(std::string& output, const std::string& separator=".", const bool trailing=true) const;
index 63207ad66dac11f09f89a6eb926c082730c56a4c..cf24bacd77ae625bded7136af7fc846f8dd58c75 100644 (file)
@@ -1042,7 +1042,7 @@ BOOST_AUTO_TEST_CASE(test_raw_data_comparison) {
     const std::string_view raw(reinterpret_cast<const char*>(query.data()) + sizeof(dnsheader), query.size() - sizeof(dnsheader));
     BOOST_CHECK(aroot.matches(raw));
 
-    DNSName differentCase("A.RooT-Servers.NET");
+    const DNSName differentCase("A.RooT-Servers.NET");
     BOOST_CHECK(differentCase.matches(raw));
 
     const DNSName broot("b.root-servers.net");