Skip to content

Commit c61324b

Browse files
committed
[#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'
1 parent 6b988f8 commit c61324b

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/lib/cc/data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class Element {
136136
///
137137
/// any is a special type used in list specifications, specifying that the
138138
/// elements can be of any type.
139-
enum types {
139+
enum types : int {
140140
integer = 0,
141141
real = 1,
142142
boolean = 2,

src/lib/dns/message.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class Message {
199199
/// introducing a separately defined class considering the balance
200200
/// between the complexity and advantage, but hopefully the cast notation
201201
/// is sufficiently ugly to prevent proliferation of the usage.
202-
enum HeaderFlag {
202+
enum HeaderFlag : int {
203203
HEADERFLAG_QR = 0x8000, // Query (if cleared) or response (if set)
204204
HEADERFLAG_AA = 0x0400, // Authoritative answer
205205
HEADERFLAG_TC = 0x0200, // Truncation
@@ -239,7 +239,7 @@ class Message {
239239
///
240240
/// <b>Future Extension:</b> We'll probably also define constants for
241241
/// the section names used in dynamic updates in future versions.
242-
enum Section {
242+
enum Section : int {
243243
SECTION_QUESTION = 0, // Question section
244244
SECTION_ANSWER = 1, // Answer section
245245
SECTION_AUTHORITY = 2, // Authority section

src/lib/eval/token.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ class TokenPkt : public Token {
542542
public:
543543

544544
/// @brief enum value that determines the field.
545-
enum MetadataType {
545+
enum MetadataType : int {
546546
IFACE, ///< interface name (string)
547547
SRC, ///< source (IP address)
548548
DST, ///< destination (IP address)
@@ -591,7 +591,7 @@ class TokenPkt4 : public Token {
591591
public:
592592

593593
/// @brief enum value that determines the field.
594-
enum FieldType {
594+
enum FieldType : int {
595595
CHADDR, ///< chaddr field (up to 16 bytes link-layer address)
596596
GIADDR, ///< giaddr (IPv4 address)
597597
CIADDR, ///< ciaddr (IPv4 address)
@@ -644,7 +644,7 @@ class TokenPkt4 : public Token {
644644
class TokenPkt6 : public Token {
645645
public:
646646
/// @brief enum value that determines the field.
647-
enum FieldType {
647+
enum FieldType : int {
648648
MSGTYPE, ///< msg type
649649
TRANSID ///< transaction id (integer but manipulated as a string)
650650
};
@@ -696,7 +696,7 @@ class TokenRelay6Field : public Token {
696696
public:
697697

698698
/// @brief enum value that determines the field.
699-
enum FieldType {
699+
enum FieldType : int {
700700
PEERADDR, ///< Peer address field (IPv6 address)
701701
LINKADDR ///< Link address field (IPv6 address)
702702
};
@@ -1091,7 +1091,7 @@ class TokenVendor : public TokenOption {
10911091
public:
10921092

10931093
/// @brief Specifies a field of the vendor option
1094-
enum FieldType {
1094+
enum FieldType : int {
10951095
SUBOPTION, ///< If this token fetches a suboption, not a field.
10961096
ENTERPRISE_ID, ///< enterprise-id field (vendor-info, vendor-class)
10971097
EXISTS, ///< vendor[123].exists

0 commit comments

Comments
 (0)