Skip to content

Reject unrepresentable body lengths in Frame.serialize() - #176

Open
AryanRG wants to merge 1 commit into
python-hyper:masterfrom
AryanRG:fix/frame-serialize-length-bound
Open

AryanRG wants to merge 1 commit into
python-hyper:masterfrom
AryanRG:fix/frame-serialize-length-bound

Conversation

@AryanRG

@AryanRG AryanRG commented Oct 17, 2026

Copy link
Copy Markdown

Frame.serialize() currently emits a body of 16,777,216 bytes with a zero-length header because the length is truncated to 24 bits. Reject bodies above FRAME_MAX_ALLOWED_LEN with InvalidFrameError before building the header, while preserving the valid 16,777,215-byte boundary. The check includes padding and other serialized body overhead.

Seven regression cases cover DATA and CONTINUATION maximum-size round trips, rejection at maximum plus one and plus two, and overflow caused by the PADDED length byte. Includes a changelog entry naming Frame.serialize().

ExtensionFrame.serialize() is a separate override and remains outside this patch; #169 addresses its stale body length. Peer-negotiated lower frame limits remain the caller's responsibility, and the check runs after body allocation. This is separate from the SETTINGS flag handling in #175 and header parsing tests in #173.

Validation on macOS ARM64 / CPython 3.14.4: 155 tests passed, including the pinned HTTP/2 fixture collection, with 100% statement and branch coverage. Configured source Ruff, strict mypy, HTML documentation, and whitespace checks passed. Five of the seven regression cases failed against the original runtime source. Other platforms and Python versions were not run locally.

AI assistance was used for the investigation, implementation, tests, validation, and PR text.

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