summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2024-06-20 12:27:54 +0200
committerAndrei Pavel <andrei@isc.org>2024-06-20 18:32:20 +0200
commitc61324b545e69c6fd61f738aba121128c736bebf (patch)
treec42ec4bea97d5c9d051b9e94bde10826366ffc3d
parent[#3287] address review (diff)
downloadkea-c61324b545e69c6fd61f738aba121128c736bebf.tar.xz
kea-c61324b545e69c6fd61f738aba121128c736bebf.zip
[#3323] typed enums to appease ubsan
example of UBSan error: runtime error: load of value 65536, which is not a valid value for type 'const HeaderFlag'
-rw-r--r--src/lib/cc/data.h2
-rw-r--r--src/lib/dns/message.h4
-rw-r--r--src/lib/eval/token.h10
3 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/cc/data.h b/src/lib/cc/data.h
index c6925138f3..a4be0ed674 100644
--- a/src/lib/cc/data.h
+++ b/src/lib/cc/data.h
@@ -136,7 +136,7 @@ public:
///
/// any is a special type used in list specifications, specifying that the
/// elements can be of any type.
- enum types {
+ enum types : int {
integer = 0,
real = 1,
boolean = 2,
diff --git a/src/lib/dns/message.h b/src/lib/dns/message.h
index d5c57950d0..1dea110ddb 100644
--- a/src/lib/dns/message.h
+++ b/src/lib/dns/message.h
@@ -199,7 +199,7 @@ public:
/// introducing a separately defined class considering the balance
/// between the complexity and advantage, but hopefully the cast notation
/// is sufficiently ugly to prevent proliferation of the usage.
- enum HeaderFlag {
+ enum HeaderFlag : int {
HEADERFLAG_QR = 0x8000, // Query (if cleared) or response (if set)
HEADERFLAG_AA = 0x0400, // Authoritative answer
HEADERFLAG_TC = 0x0200, // Truncation
@@ -239,7 +239,7 @@ public:
///
/// <b>Future Extension:</b> We'll probably also define constants for
/// the section names used in dynamic updates in future versions.
- enum Section {
+ enum Section : int {
SECTION_QUESTION = 0, // Question section
SECTION_ANSWER = 1, // Answer section
SECTION_AUTHORITY = 2, // Authority section
diff --git a/src/lib/eval/token.h b/src/lib/eval/token.h
index b37a9867d5..9f0c10d99b 100644
--- a/src/lib/eval/token.h
+++ b/src/lib/eval/token.h
@@ -542,7 +542,7 @@ class TokenPkt : public Token {
public:
/// @brief enum value that determines the field.
- enum MetadataType {
+ enum MetadataType : int {
IFACE, ///< interface name (string)
SRC, ///< source (IP address)
DST, ///< destination (IP address)
@@ -591,7 +591,7 @@ class TokenPkt4 : public Token {
public:
/// @brief enum value that determines the field.
- enum FieldType {
+ enum FieldType : int {
CHADDR, ///< chaddr field (up to 16 bytes link-layer address)
GIADDR, ///< giaddr (IPv4 address)
CIADDR, ///< ciaddr (IPv4 address)
@@ -644,7 +644,7 @@ private:
class TokenPkt6 : public Token {
public:
/// @brief enum value that determines the field.
- enum FieldType {
+ enum FieldType : int {
MSGTYPE, ///< msg type
TRANSID ///< transaction id (integer but manipulated as a string)
};
@@ -696,7 +696,7 @@ class TokenRelay6Field : public Token {
public:
/// @brief enum value that determines the field.
- enum FieldType {
+ enum FieldType : int {
PEERADDR, ///< Peer address field (IPv6 address)
LINKADDR ///< Link address field (IPv6 address)
};
@@ -1091,7 +1091,7 @@ class TokenVendor : public TokenOption {
public:
/// @brief Specifies a field of the vendor option
- enum FieldType {
+ enum FieldType : int {
SUBOPTION, ///< If this token fetches a suboption, not a field.
ENTERPRISE_ID, ///< enterprise-id field (vendor-info, vendor-class)
EXISTS, ///< vendor[123].exists