Skip to content

Reject malformed OSC bundle element lengths - #201

Open
civilwarinfrance wants to merge 1 commit into
attwad:mainfrom
civilwarinfrance:fix/bundle-element-lengths
Open

civilwarinfrance wants to merge 1 commit into
attwad:mainfrom
civilwarinfrance:fix/bundle-element-lengths

Conversation

@civilwarinfrance

Copy link
Copy Markdown

A bundle element with size -4 leaves the parser at the same offset, so it loops forever. Oversized elements can also be accepted even though their contents extend past the packet.

Check that each element length is positive, aligned to four bytes and fits inside the datagram before parsing it. Invalid lengths now raise the existing ParseError, including inside nested bundles. Empty bundles remain valid.

Added regression cases for malformed, oversized and nested elements. Also corrected the declared lengths in two older valid-packet fixtures. The original negative-length loop was reproduced in a bounded subprocess; the oversized/nested cases fail on unchanged main.

All 184 tests and 10 subtests pass locally, along with project-wide Ruff formatting/lint and mypy checks. Tested on macOS/Python 3.14; hosted CI covers the other environments.

AI assistance: OpenAI Codex wrote and tested this patch.

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