diff --git a/src/common/HPM.c b/src/common/HPM.c index 9608eec218e..3fc3c04a8d8 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -190,6 +190,9 @@ static bool hplugins_addpacket(unsigned short cmd, unsigned short length, void ( if (cmd <= MAX_PACKET_DB && cmd >= MIN_PACKET_DB) { packets->db[cmd] = length; + } else { + ShowError("HPM->addPacket:%s: packet 0x%04x is out of range! Packet ID must be between 0x%04x (MIN_PACKET_DB) and 0x%04x (MAX_PACKET_DB). Ignoring it...\n", + HPM->pid2name(pluginID), cmd, (unsigned int) MIN_PACKET_DB, (unsigned int) MAX_PACKET_DB); } return true; diff --git a/src/common/packets.h b/src/common/packets.h index a4dea570a07..e1aecfd3bae 100644 --- a/src/common/packets.h +++ b/src/common/packets.h @@ -30,6 +30,8 @@ #define MAX_PACKET_DB 0x0F00 #endif +STATIC_ASSERT(MAX_PACKET_DB <= USHRT_MAX, "MAX_PACKET_DB must not exceed 2 bytes (USHRT_MAX / 65,535)"); + #ifndef MIN_INTIF_PACKET_DB #define MIN_INTIF_PACKET_DB 0x3800 #endif