BIND 10 trac2850_3, updated. 34a551b679d654f6c7dda77d54e1f2ae22f620b2 [2850] Reject empty names too in setNamedAddress()
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed May 15 12:56:43 UTC 2013
The branch, trac2850_3 has been updated
via 34a551b679d654f6c7dda77d54e1f2ae22f620b2 (commit)
via 8844627524fc6aa786caa3edc260ccd667b37c84 (commit)
from 41e93e6434d76b61ef2d4b75192dac4a4019f649 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 34a551b679d654f6c7dda77d54e1f2ae22f620b2
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed May 15 18:26:13 2013 +0530
[2850] Reject empty names too in setNamedAddress()
commit 8844627524fc6aa786caa3edc260ccd667b37c84
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed May 15 18:21:26 2013 +0530
[2850] Reserve names beginning with _ for internal use only
-----------------------------------------------------------------------
Summary of changes:
src/lib/util/memory_segment.h | 17 +++++++++++++++++
.../util/tests/memory_segment_common_unittest.cc | 6 ++++++
2 files changed, 23 insertions(+)
-----------------------------------------------------------------------
diff --git a/src/lib/util/memory_segment.h b/src/lib/util/memory_segment.h
index a93b5ad..2563112 100644
--- a/src/lib/util/memory_segment.h
+++ b/src/lib/util/memory_segment.h
@@ -171,6 +171,15 @@ 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 (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
/// to \c allocate(). The actual implementation is encouraged to detect
@@ -230,6 +239,14 @@ public:
isc_throw(InvalidParameter,
"NULL name is given to setNamedAddress");
}
+ 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.");
+ }
return (setNamedAddressImpl(name, addr));
}
diff --git a/src/lib/util/tests/memory_segment_common_unittest.cc b/src/lib/util/tests/memory_segment_common_unittest.cc
index fac0559..2da7751 100644
--- a/src/lib/util/tests/memory_segment_common_unittest.cc
+++ b/src/lib/util/tests/memory_segment_common_unittest.cc
@@ -42,6 +42,12 @@ 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);
+
// we can now get it; the stored value should be intact.
MemorySegment::NamedAddressResult result =
segment.getNamedAddress("test address");
More information about the bind10-changes
mailing list