Bound LCM protocol payloads#90
Open
mjc wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the LCM (Light Control Module) protocol handling by bounding/normalizing incoming fields before storing them and before forwarding them back out, preventing out-of-bounds copies and invalid/stale payload behavior.
Changes:
- Bound and null-terminate copied LCM name strings to avoid overruns.
- Clamp brightness bytes to the protocol’s 0–100 range and cap stored/forwarded payload length to fixed capacity.
- Reset per-request payload state and simplify the enabled-only light-control handler.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mjc
marked this pull request as draft
July 14, 2026 20:23
mjc
marked this pull request as ready for review
July 14, 2026 20:39
mjc
marked this pull request as draft
July 14, 2026 20:43
mjc
marked this pull request as ready for review
July 14, 2026 20:43
lukash
reviewed
Jul 19, 2026
lukash
left a comment
Owner
There was a problem hiding this comment.
I think the changes in the two commits in this PR should ideally be split into 3 commits:
- the simplification of the name copying code
- limiting the brightnesses to max 100
- handling the payload size overflow / clearing on short request
mjc
force-pushed
the
refloat-fix-lcm-protocol
branch
from
July 20, 2026 16:42
d9bf0b3 to
dff2465
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bounds LCM protocol inputs before storing or forwarding them.
Changes
Behavior
Valid LCM traffic is unchanged. Oversized names and payloads stay within their fixed buffers, and a rejected short light-control request cannot leave an older payload queued for the next poll response.
I was able to cause a crash on the existing code with enough BTLE packets.