Commit 22bd4680 authored by Francis Dupont's avatar Francis Dupont
Browse files


[576-cb-cmds-empty-value-for-next-server-parameter-is-accepted-which-causes-misconfiguration] Protected getSiaddr against global being empty string
parent e4fde183
......@@ -8,6 +8,7 @@
#define NETWORK_H
#include <asiolink/io_address.h>
#include <asiolink/io_error.h>
#include <cc/cfg_to_element.h>
#include <cc/data.h>
#include <cc/element_value.h>
......@@ -850,8 +851,13 @@ public:
/// @return siaddr value
getSiaddr(const Inheritance& inheritance = Inheritance::ALL) const {
return (getProperty<Network4>(&Network4::getSiaddr, siaddr_,
inheritance, "next-server"));
// Temporary fix for global next-server being the empty string.
try {
return (getProperty<Network4>(&Network4::getSiaddr, siaddr_,
inheritance, "next-server"));
} catch (asiolink::IOError) {
return (siaddr_);
/// @brief Sets server hostname for the network.
......@@ -404,4 +404,19 @@ TEST_F(NetworkTest, getPropertyGlobalNoParentNoChild) {
EXPECT_EQ("global_iface", net_child->getIface().get());
// Test that getSiaddr() never fails.
TEST_F(NetworkTest, getSiaddrNeverFail) {
TestNetworkPtr net_child(new TestNetwork4());
// Set the next-server textual address to the empty string.
// Note that IOAddress("") throws IOError.
globals_->set("next-server", Element::create(""));
// Get an IPv4 view of the test network.
auto net4_child = boost::dynamic_pointer_cast<Network4>(net_child);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment