]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2850] Reject empty names too in setNamedAddress()
authorMukund Sivaraman <muks@isc.org>
Wed, 15 May 2013 12:56:13 +0000 (18:26 +0530)
committerMukund Sivaraman <muks@isc.org>
Mon, 20 May 2013 06:46:06 +0000 (12:16 +0530)
src/lib/util/memory_segment.h
src/lib/util/tests/memory_segment_common_unittest.cc

index 0332b2419dcdb346f46d7543ba0b664477ff9122..256311230198945bcda8751c4b3e3b45108fe352 100644 (file)
@@ -171,9 +171,14 @@ public:
     /// corresponding address by that name (in such cases the real address
     /// may be different between these two processes).
     ///
-    /// Note that names beginning with an underscore ("_") are reserved
-    /// for internal use by this class. If such a name is passed to this
-    /// method, an isc::InvalidParameter exception will be thrown.
+    /// Note that names beginning with an underscore (such as
+    /// \c "_example") are reserved for internal use by this class. If such
+    /// a name is passed to this method, an \c isc::InvalidParameter
+    /// exception will be thrown.
+    ///
+    /// Note that empty names (\c "") are not allowed too. If an empty name
+    /// is passed to this method, an \c isc::InvalidParameter exception
+    /// will be thrown.
     ///
     /// \c addr must be 0 (NULL) or an address that belongs to this segment.
     /// The latter case means it must be the return value of a previous call
@@ -234,7 +239,10 @@ public:
             isc_throw(InvalidParameter,
                       "NULL name is given to setNamedAddress");
         }
-        if (*name == '_') {
+        if (*name == '\0') {
+            isc_throw(InvalidParameter,
+                      "Empty name was passed to setNamedAddress");
+        } else if (*name == '_') {
             isc_throw(InvalidParameter,
                       "Names beginning with _ are reserved for "
                       "internal use only.");
index b638e0bb735ed04cf7321480e3df9d8479c6addf..2da775154a1071f907787c77466c90a7055dc913 100644 (file)
@@ -42,6 +42,9 @@ checkSegmentNamedAddress(MemorySegment& segment, bool out_of_segment_ok) {
     // NULL name isn't allowed.
     EXPECT_THROW(segment.setNamedAddress(NULL, ptr32), InvalidParameter);
 
+    // Empty names are not allowed.
+    EXPECT_THROW(segment.setNamedAddress("", ptr32), InvalidParameter);
+
     // Names beginning with _ are not allowed.
     EXPECT_THROW(segment.setNamedAddress("_foo", ptr32), InvalidParameter);