Skip to content

Add static_assert to guard MAX_DATA_LEN against control channel underflow - #16

Merged
gabryelreyes merged 3 commits into
feature/max_payload_sizefrom
copilot/sub-pr-15
Feb 27, 2026
Merged

gabryelreyes merged 3 commits into
feature/max_payload_sizefrom
copilot/sub-pr-15

Conversation

Copilot AI commented Feb 27, 2026 •

Copy link
Copy Markdown
Contributor

When MAX_DATA_LEN is overridden by a consumer, it must be at least as large as ControlChannelPayload (16 bytes) or channel 0 send/receive will overflow the payload buffer. Previously there was no enforcement of this constraint.

Changes

  • src/SerialMuxProtCommon.hpp: Added static_assert after the ControlChannelPayload typedef to enforce the minimum size at compile time:
static_assert(MAX_DATA_LEN >= sizeof(ControlChannelPayload),
              "MAX_DATA_LEN must be >= sizeof(ControlChannelPayload) to avoid buffer overflows on control channel.");

Defining MAX_DATA_LEN below 16 now produces a clear compiler error indicating the failing size comparison, e.g. the comparison reduces to '(4 >= 16)'.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 27, 2026 13:29
…load)

Co-authored-by: gabryelreyes <66941456+gabryelreyes@users.noreply.github.com>
Co-authored-by: gabryelreyes <66941456+gabryelreyes@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Address feedback on custom MAX_DATA_LEN implementation Add static_assert to guard MAX_DATA_LEN against control channel underflow Feb 27, 2026
@gabryelreyes
gabryelreyes marked this pull request as ready for review February 27, 2026 13:33
@gabryelreyes
gabryelreyes merged commit 7fa015e into feature/max_payload_size Feb 27, 2026
10 checks passed
@gabryelreyes
gabryelreyes deleted the copilot/sub-pr-15 branch February 27, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants