2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 05:27:55 +00:00

[#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'
This commit is contained in:
Andrei Pavel 2024-06-20 13:27:54 +03:00
parent 6b988f8cc8
commit c61324b545
No known key found for this signature in database
GPG Key ID: D4E804481939CB21
3 changed files with 8 additions and 8 deletions

View File

@ -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,

View File

@ -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

View File

@ -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