Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validations/alerts for packet ranges #3309

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/common/HPM.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/common/packets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading