diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | doc/sphinx/arm/dhcp4-srv.rst | 3 | ||||
-rw-r--r-- | src/lib/dhcp/option4_client_fqdn.cc | 11 | ||||
-rw-r--r-- | src/lib/dhcp/tests/option4_client_fqdn_unittest.cc | 22 | ||||
-rw-r--r-- | src/lib/dhcpsrv/alloc_engine.cc | 4 | ||||
-rw-r--r-- | src/lib/util/buffer.h | 2 |
6 files changed, 41 insertions, 7 deletions
@@ -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 diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index eea264844b..41e2c261c2 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -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 ----------------------------- diff --git a/src/lib/dhcp/option4_client_fqdn.cc b/src/lib/dhcp/option4_client_fqdn.cc index cb90728ab8..cc463dfe9f 100644 --- a/src/lib/dhcp/option4_client_fqdn.cc +++ b/src/lib/dhcp/option4_client_fqdn.cc @@ -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()); + } } } diff --git a/src/lib/dhcp/tests/option4_client_fqdn_unittest.cc b/src/lib/dhcp/tests/option4_client_fqdn_unittest.cc index 27987fc479..984ffe4224 100644 --- a/src/lib/dhcp/tests/option4_client_fqdn_unittest.cc +++ b/src/lib/dhcp/tests/option4_client_fqdn_unittest.cc @@ -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 diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index a74eca9415..f963df97f4 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -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 diff --git a/src/lib/util/buffer.h b/src/lib/util/buffer.h index ef1f529058..7ae841e0d9 100644 --- a/src/lib/util/buffer.h +++ b/src/lib/util/buffer.h @@ -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 @c 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, |