]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#716,!412] Reject "any" keyword as a server tag.
authorMarcin Siodelski <marcin@isc.org>
Tue, 9 Jul 2019 15:34:58 +0000 (17:34 +0200)
committerMarcin Siodelski <marcin@isc.org>
Tue, 9 Jul 2019 18:37:29 +0000 (14:37 -0400)
src/lib/cc/server_tag.cc
src/lib/cc/server_tag.h
src/lib/cc/tests/server_tag_unittest.cc

index 56b20aa31d42cb01e87a405dbdab097dcd38904b..cf68d67fb9c475ad4ae07a9edb7ee989e28c760c 100644 (file)
@@ -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
index abfa75036c705e6a62d934e29bdad15b968dfaa9..6f8001527e00407c03580bcc2b99210bb8863fad 100644 (file)
@@ -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:
 
index f782a065a0ef11b4c45959fdd010eedbe3391d6a..523be743796367124733d1eadac200efd24bf710 100644 (file)
@@ -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);
+    }
 }
 
 }