From: Marcin Siodelski Date: Tue, 9 Jul 2019 15:34:58 +0000 (+0200) Subject: [#716,!412] Reject "any" keyword as a server tag. X-Git-Tag: Kea-1.6.0-beta2~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3395f1f31d0aa69c3f97dedac0fa8178b2fa592;p=thirdparty%2Fkea.git [#716,!412] Reject "any" keyword as a server tag. --- diff --git a/src/lib/cc/server_tag.cc b/src/lib/cc/server_tag.cc index 56b20aa31d..cf68d67fb9 100644 --- a/src/lib/cc/server_tag.cc +++ b/src/lib/cc/server_tag.cc @@ -28,6 +28,12 @@ ServerTag::ServerTag(const std::string& tag) } boost::algorithm::to_lower(tag_); + + // ANY has a defined meaning for server selector and must not be used as + // a server tag. + if (tag_ == "any") { + isc_throw(BadValue, "'any' is reserved and must not be used as a server-tag"); + } } bool diff --git a/src/lib/cc/server_tag.h b/src/lib/cc/server_tag.h index abfa75036c..6f8001527e 100644 --- a/src/lib/cc/server_tag.h +++ b/src/lib/cc/server_tag.h @@ -18,8 +18,10 @@ namespace data { /// configuration is stored in the database. The label "all" is reserved /// and it means "all servers". A configuration object in the database /// associated with this server tag belongs to all servers. The server -/// tag must not be empty and must not be longer than 256 characters -/// (excluding leading and terminating whitespaces, which are trimmed). +/// tag must not be empty, must not be longer than 256 characters +/// (excluding leading and terminating whitespaces, which are trimmed) +/// and must not be set to "any" which has a special meaning for the +/// server selector. class ServerTag { public: diff --git a/src/lib/cc/tests/server_tag_unittest.cc b/src/lib/cc/tests/server_tag_unittest.cc index f782a065a0..523be74379 100644 --- a/src/lib/cc/tests/server_tag_unittest.cc +++ b/src/lib/cc/tests/server_tag_unittest.cc @@ -87,6 +87,11 @@ TEST(ServerTagTest, malformed) { SCOPED_TRACE("too long tag, max is 256"); EXPECT_THROW(ServerTag(std::string(257, 'c')), BadValue); } + + { + SCOPED_TRACE("use reserved keyword any as a tag"); + EXPECT_THROW(ServerTag("any"), BadValue); + } } }