2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-01 06:25:34 +00:00

[2314] Validate option space name received in a configuration.

This commit is contained in:
Marcin Siodelski
2013-01-15 15:05:24 +01:00
parent 7d4b55818c
commit 77c9f2b09e
2 changed files with 17 additions and 13 deletions

View File

@@ -768,7 +768,10 @@ private:
} }
std::string option_space = getParam<std::string>("space", string_values_); std::string option_space = getParam<std::string>("space", string_values_);
/// @todo Validate option space once #2313 is merged. if (!OptionSpace::validateName(option_space)) {
isc_throw(DhcpConfigError, "invalid option space name'"
<< option_space << "'");
}
OptionDefinitionPtr def; OptionDefinitionPtr def;
if (option_space == "dhcp4" && if (option_space == "dhcp4" &&
@@ -978,7 +981,7 @@ public:
/// @brief Parser for a single option definition. /// @brief Parser for a single option definition.
/// ///
/// This parser creates an instance of a single option definition. /// This parser creates an instance of a single option definition.
class OptionDefParser: DhcpConfigParser { class OptionDefParser : public DhcpConfigParser {
public: public:
/// @brief Constructor. /// @brief Constructor.
@@ -1055,8 +1058,8 @@ public:
/// @brief Stores the parsed option definition in a storage. /// @brief Stores the parsed option definition in a storage.
void commit() { void commit() {
// @todo validate option space name once 2313 is merged. if (storage_ && option_definition_ &&
if (storage_ && option_definition_) { OptionSpace::validateName(option_space_name_)) {
storage_->addItem(option_definition_, option_space_name_); storage_->addItem(option_definition_, option_space_name_);
} }
} }
@@ -1078,11 +1081,10 @@ private:
void createOptionDef() { void createOptionDef() {
// Get the option space name and validate it. // Get the option space name and validate it.
std::string space = getParam<std::string>("space", string_values_); std::string space = getParam<std::string>("space", string_values_);
// @todo uncomment the code below when the #2313 is merged. if (!OptionSpace::validateName(space)) {
/* if (!OptionSpace::validateName()) {
isc_throw(DhcpConfigError, "invalid option space name '" isc_throw(DhcpConfigError, "invalid option space name '"
<< space << "'"); << space << "'");
} */ }
// Get other parameters that are needed to create the // Get other parameters that are needed to create the
// option definition. // option definition.

View File

@@ -798,7 +798,10 @@ private:
} }
std::string option_space = getParam<std::string>("space", string_values_); std::string option_space = getParam<std::string>("space", string_values_);
/// @todo Validate option space once #2313 is merged. if (!OptionSpace::validateName(option_space)) {
isc_throw(DhcpConfigError, "invalid option space name'"
<< option_space << "'");
}
OptionDefinitionPtr def; OptionDefinitionPtr def;
if (option_space == "dhcp6" && if (option_space == "dhcp6" &&
@@ -1085,8 +1088,8 @@ public:
/// @brief Stores the parsed option definition in the data store. /// @brief Stores the parsed option definition in the data store.
void commit() { void commit() {
// @todo validate option space name once 2313 is merged. if (storage_ && option_definition_ &&
if (storage_ && option_definition_) { OptionSpace::validateName(option_space_name_)) {
storage_->addItem(option_definition_, option_space_name_); storage_->addItem(option_definition_, option_space_name_);
} }
} }
@@ -1108,11 +1111,10 @@ private:
void createOptionDef() { void createOptionDef() {
// Get the option space name and validate it. // Get the option space name and validate it.
std::string space = getParam<std::string>("space", string_values_); std::string space = getParam<std::string>("space", string_values_);
// @todo uncomment the code below when the #2313 is merged. if (!OptionSpace::validateName(space)) {
/* if (!OptionSpace::validateName()) {
isc_throw(DhcpConfigError, "invalid option space name '" isc_throw(DhcpConfigError, "invalid option space name '"
<< space << "'"); << space << "'");
} */ }
// Get other parameters that are needed to create the // Get other parameters that are needed to create the
// option definition. // option definition.