From: Thomas Markwalder Date: Mon, 21 Jul 2025 15:50:31 +0000 (-0400) Subject: [#3770] Addressed review comments X-Git-Tag: Kea-3.1.0~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8516a80613fec39a42ca018db1ee9649b7d6c96e;p=thirdparty%2Fkea.git [#3770] Addressed review comments modified: src/hooks/dhcp/mysql/mysql_host_data_source.cc modified: src/lib/dhcpsrv/cfg_option.cc modified: src/lib/dhcpsrv/tests/cfg_option_unittest.cc --- diff --git a/src/hooks/dhcp/mysql/mysql_host_data_source.cc b/src/hooks/dhcp/mysql/mysql_host_data_source.cc index 6644671d73..92441661a0 100644 --- a/src/hooks/dhcp/mysql/mysql_host_data_source.cc +++ b/src/hooks/dhcp/mysql/mysql_host_data_source.cc @@ -619,7 +619,7 @@ public: // Convert user_context to string as well. std::string user_context; if (user_context_null_ == MLM_FALSE) { - user_context_[user_context_length_] = '\0'; + user_context_[user_context_length_ - 1] = '\0'; user_context.assign(user_context_); } @@ -949,7 +949,7 @@ private: if (space_null_ == MLM_FALSE) { // Typically, the string values returned by the database are not // NULL terminated. - space_[space_length_] = '\0'; + space_[space_length_ - 1] = '\0'; space.assign(space_); } @@ -962,21 +962,21 @@ private: // Convert formatted_value to string. std::string formatted_value; if (formatted_value_null_ == MLM_FALSE) { - formatted_value_[formatted_value_length_] = '\0'; + formatted_value_[formatted_value_length_ - 1] = '\0'; formatted_value.assign(formatted_value_); } // Convert user_context to string. std::string user_context; if (user_context_null_ == MLM_FALSE) { - user_context_[user_context_length_] = '\0'; + user_context_[user_context_length_ - 1] = '\0'; user_context.assign(user_context_); } // Convert client classes to string. std::string client_classes; if (client_classes_null_ == MLM_FALSE) { - client_classes_[client_classes_length_] = '\0'; + client_classes_[client_classes_length_ - 1] = '\0'; client_classes.assign(client_classes_); } diff --git a/src/lib/dhcpsrv/cfg_option.cc b/src/lib/dhcpsrv/cfg_option.cc index 3db4eb99ad..428a4f114d 100644 --- a/src/lib/dhcpsrv/cfg_option.cc +++ b/src/lib/dhcpsrv/cfg_option.cc @@ -440,7 +440,7 @@ CfgOption::del(const std::string& option_space, const uint16_t option_code, for (auto const& option_it : *options_in_space) { // Check if the option encapsulates our option space and - // it does, try to delete our option. + // if it does, try to delete our option. if (option_it.option_ && (option_it.option_->getEncapsulatedSpace() == option_space)) { option_it.option_->delOption(option_code); diff --git a/src/lib/dhcpsrv/tests/cfg_option_unittest.cc b/src/lib/dhcpsrv/tests/cfg_option_unittest.cc index bf53a6ea1b..fa34d51b21 100644 --- a/src/lib/dhcpsrv/tests/cfg_option_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_option_unittest.cc @@ -1559,7 +1559,7 @@ TEST_F(CfgOptionTest, replaceWithClientClasses) { // Replace the first reference option. auto& replacement = reference_options[0]; (boost::dynamic_pointer_cast(replacement.option_))->setValue(100); - ASSERT_NO_THROW(cfg.replace(replacement, DHCP6_OPTION_SPACE)); + ASSERT_NO_THROW(cfg.replace(OptionDescriptor(replacement), DHCP6_OPTION_SPACE)); // Make sure we can get the updated option. OptionDescriptor found_desc = cfg.get(DHCP6_OPTION_SPACE, 777,