]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3289] New fix
authorFrancis Dupont <fdupont@isc.org>
Fri, 5 Apr 2024 16:10:46 +0000 (18:10 +0200)
committerFrancis Dupont <fdupont@isc.org>
Fri, 5 Apr 2024 16:10:46 +0000 (18:10 +0200)
ChangeLog
doc/sphinx/arm/dhcp4-srv.rst
src/lib/dhcp/option4_client_fqdn.cc
src/lib/dhcp/tests/option4_client_fqdn_unittest.cc
src/lib/dhcpsrv/alloc_engine.cc
src/lib/util/buffer.h

index 32332ca0a8180d3bc9740bc062994c685f84f6f7..d63eb3a33e60b4323c40fa5072053407402bc3b8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2217.  [func]          fdupont
+       Extended the lenient-option-parsing compatibility
+       flag to ignore DHCPv4 fqdn (81) option with some
+       invalid domain names (e.g. beginning with an empty label).
+       (Gitlab 3289)
+
 2216.  [func]          tmark
        PerfMon hook library is now functional. It accumulates
        and reports performance data, and supports alarms. Still
index eea264844b4421326a9d66b0280ba01706526fec..41e2c261c27153a50b37dc9adf68c3de0501f287 100644 (file)
@@ -8228,6 +8228,9 @@ or in terms of the log message above, the tuple length ``y`` becomes ``x``.
       }
     }
 
+Starting with Kea version 2.5.8 this is extended to silently ignore
+fqdn (81) options with some invalid domain names.
+
 Ignore DHCP Server Identifier
 -----------------------------
 
index cb90728ab8eaf7354f37ca2ff8c5f559da609617..cc463dfe9fb2db4f0169cd530905aa2a998b6144 100644 (file)
@@ -272,9 +272,14 @@ Option4ClientFqdnImpl::parseWireData(OptionBufferConstIter first,
 
         }
     } catch (const Exception& ex) {
-        isc_throw(InvalidOption4FqdnDomainName,
-                  "failed to parse the domain-name in DHCPv4 Client FQDN"
-                  << " Option: " << ex.what());
+        std::ostringstream errmsg;
+        errmsg << "failed to parse the domain-name in DHCPv4 Client FQDN "
+               << " Option: " << ex.what();
+        if (Option::lenient_parsing_) {
+            isc_throw(SkipThisOptionError, errmsg.str());
+        } else {
+            isc_throw(InvalidOption4FqdnDomainName, errmsg.str());
+        }
     }
 }
 
index 27987fc4791b609090f7045a1d456877d33e0d85..984ffe422450f47d6fec57d4a845dbd63e2246d3 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2024 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -16,6 +16,18 @@ namespace {
 using namespace isc;
 using namespace isc::dhcp;
 
+// RAII device to make sure that lenient parsing flag is reset to false on exit.
+class LenientOptionParsing {
+public:
+    LenientOptionParsing(bool value) {
+        Option::lenient_parsing_ = value;
+    }
+
+    ~LenientOptionParsing() {
+        Option::lenient_parsing_ = false;
+    }
+};
+
 // This test verifies that constructor accepts empty partial domain-name but
 // does not accept empty fully qualified domain name.
 TEST(Option4ClientFqdnTest, constructEmptyName) {
@@ -222,8 +234,12 @@ TEST(Option4ClientFqdnTest, constructFromWireInvalidName) {
     size_t in_data_size = sizeof(in_data) / sizeof(in_data[0]);
     OptionBuffer in_buf(in_data, in_data + in_data_size);
 
+    LenientOptionParsing lop(false);
     EXPECT_THROW(Option4ClientFqdn(in_buf.begin(), in_buf.end()),
                  InvalidOption4FqdnDomainName);
+    Option::lenient_parsing_ = true;
+    EXPECT_THROW(Option4ClientFqdn(in_buf.begin(), in_buf.end()),
+                 SkipThisOptionError);
 }
 
 // This test verifies that exception is thrown when invalid domain-name
@@ -240,8 +256,12 @@ TEST(Option4ClientFqdnTest, constructFromWireInvalidASCIIName) {
     size_t in_data_size = sizeof(in_data) / sizeof(in_data[0]);
     OptionBuffer in_buf(in_data, in_data + in_data_size);
 
+    LenientOptionParsing lop(false);
     EXPECT_THROW(Option4ClientFqdn(in_buf.begin(), in_buf.end()),
                  InvalidOption4FqdnDomainName);
+    Option::lenient_parsing_ = true;
+    EXPECT_THROW(Option4ClientFqdn(in_buf.begin(), in_buf.end()),
+                 SkipThisOptionError);
 }
 
 // This test verifies that the option in the on-wire format with partial
index a74eca94152bae81aa995b29747796039706d83d..f963df97f42df92e3653547f246522760361593e 100644 (file)
@@ -56,11 +56,11 @@ namespace {
 
 /// Structure that holds registered hook indexes
 struct AllocEngineHooks {
-    int hook_index_lease4_select_; ///< index for "lease4_receive" hook point
+    int hook_index_lease4_select_; ///< index for "lease4_select" hook point
     int hook_index_lease4_renew_;  ///< index for "lease4_renew" hook point
     int hook_index_lease4_expire_; ///< index for "lease4_expire" hook point
     int hook_index_lease4_recover_;///< index for "lease4_recover" hook point
-    int hook_index_lease6_select_; ///< index for "lease6_receive" hook point
+    int hook_index_lease6_select_; ///< index for "lease6_select" hook point
     int hook_index_lease6_renew_;  ///< index for "lease6_renew" hook point
     int hook_index_lease6_rebind_; ///< index for "lease6_rebind" hook point
     int hook_index_lease6_expire_; ///< index for "lease6_expire" hook point
index ef1f52905814a573f558e1e0027dd43d68618828..7ae841e0d9c29055fbcc3a14a5d68ced8f83b9fb 100644 (file)
@@ -298,7 +298,7 @@ typedef boost::shared_ptr<InputBuffer> InputBufferPtr;
 ///  sendto(s, buffer.getDataAsVoidPtr(), buffer.getLength(), 0, &to, sizeof(to));
 /// @endcode
 ///
-/// where the @c getData() (in fact @getDataAsVoidPtr()) method gives
+/// where the @c getData() (in fact @getDataAsVoidPtr()) method gives
 /// a reference to the internal memory region stored in the @c buffer
 /// object.  This is a suboptimal design in that it exposes an
 /// encapsulated "handle" of an object to its user.  Unfortunately,