]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2097] make sure the RRType size meets our size assumption
authorJINMEI Tatuya <jinmei@isc.org>
Sat, 11 Aug 2012 08:09:18 +0000 (01:09 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Sat, 11 Aug 2012 08:09:18 +0000 (01:09 -0700)
src/lib/datasrc/memory/rdataset.cc

index 0d9f0f8f26804c28b6cd43b82bbf12b00a2659ea..176844dee03b2f82b6d97056abc080e9a4c91a9a 100644 (file)
@@ -18,6 +18,9 @@
 #include "rdataset.h"
 #include "rdata_encoder.h"
 
+#include <boost/static_assert.hpp>
+
+#include <stdint.h>
 #include <cstring>
 #include <new>                  // for the placement new
 
@@ -69,6 +72,10 @@ RdataSet::RdataSet(RRType type_param, size_t rdata_count_param,
     type(type_param), sig_rdata_count(sig_rdata_count_param),
     rdata_count(rdata_count_param), ttl(convertTTL(ttl_param))
 {
+    // Make sure an RRType object is essentially a plain 16-bit value, so
+    // our assumption of the size of RdataSet holds.  If it's not the case
+    // we should use the bare value instead of the class object.
+    BOOST_STATIC_ASSERT(sizeof(type) == sizeof(uint16_t));
 }
 
 } // namespace memory