Skip to content

Fix panic on malformed PrismHeader packets#1231

Open
mohammadmseet-hue wants to merge 1 commit intogoogle:masterfrom
mohammadmseet-hue:fix-prism-panic
Open

Fix panic on malformed PrismHeader packets#1231
mohammadmseet-hue wants to merge 1 commit intogoogle:masterfrom
mohammadmseet-hue:fix-prism-panic

Conversation

@mohammadmseet-hue
Copy link
Copy Markdown

Summary

Add minimum data length check and validate PrismHeader.Length in DecodeFromBytes.

Root cause: No minimum length check before reading the 24-byte header (Code, Length, DeviceName). The m.Length field from the packet is used for data[:m.Length] and data[m.Length:] slicing without validating it against len(data).

Fix: Check len(data) >= 24 before header reads. Return an error if m.Length > len(data).

All existing tests pass.

Add minimum data length check and validate PrismHeader.Length against
actual data length before using it for slicing. Malformed packets with
short data or inflated Length fields caused slice bounds panics.
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.

1 participant