Skip to content

Fix 1908 - #1912

Merged
oberstet merged 3 commits into
crossbario:masterfrom
oberstet:fix_1908
Jul 14, 2026
Merged

Fix 1908#1912
oberstet merged 3 commits into
crossbario:masterfrom
oberstet:fix_1908

Conversation

@oberstet

Copy link
Copy Markdown
Contributor

this will fix #1908 - fully TDD, in two phases ("red green test proven")

oberstet added 3 commits July 14, 2026 11:14
…rossbario#1908)

The existing TestDeflate.test_max_size asserted the buggy behavior: with
max_message_size=10 it expected the decoder to *return* a silently truncated
10-byte payload. Truncating a compressed WAMP message corrupts it, and
end_decompress_message() then raises "zlib error -3" on the mid-stream
sync-flush trailer (so the only existing decompressed-size cap never produces a
clean rejection).

Replace it with tests asserting the intended contract: a message inflating
beyond max_message_size is rejected with PayloadExceededError, both single-frame
and cumulative across frames, while under-cap and exactly-at-cap messages
round-trip intact (and end_decompress_message() does not raise). Two of these
fail on current code, proving the missing zlib unconsumed_tail drain (crossbario#1908).

Note: This work was completed with AI assistance (Claude Code).
…eanly (crossbario#1908)

decompress_message_data() passed max_message_size as zlib's max_length but never
drained unconsumed_tail, so an over-cap message was silently truncated to the cap
and the dropped tail left the deflate stream mid-token (end_decompress_message()
then raised "zlib error -3"). The cap therefore never produced a clean rejection,
and it counted per-call rather than per-message.

Track decompressed output per message (reset in start_decompress_message()) and
cap each call at the remaining budget; if unconsumed_tail is non-empty after a
call the (cumulative) message exceeds max_message_size, so raise
PayloadExceededError instead of truncating. The uncapped path (max_message_size
is None) is unchanged.

Makes the tests added in the previous commit pass: single-frame and cumulative
rejection, with under-cap and exactly-at-cap messages round-tripping intact.

Note: This work was completed with AI assistance (Claude Code).
@oberstet

Copy link
Copy Markdown
Contributor Author

phase 1 ("red"):

image

@oberstet

Copy link
Copy Markdown
Contributor Author

@oberstet
oberstet merged commit cd2dffd into crossbario:master Jul 14, 2026
45 checks passed
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.

[BUG] permessage-deflate max_message_size cap silently truncates and corrupts messages (missing unconsumed_tail drain)

1 participant