Repository navigation
Fix/eventstream prelude length check - #755
Merged
Merged
Conversation
wty-Bryant
approved these changes
Nov 23, 2026
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.
Issue #, if available:
Description of changes:
The decoder only rejected a prelude whose total length was 0. It now also rejects a total length smaller than the 16 bytes of fixed message overhead, and a headers length larger than what the total length leaves room for. Both return a
LengthErrorbefore any headers or payload are read. There is still no upper limit on message size, just the actual size of the data typeTestDecodeLimitsnow builds its 25 MB message with a consistent prelude, so it still fails on the prelude checksum rather than on the length checks. Its all-0x01input declared a headers length equal to the total length, which is now a length error.On the encoding side,
Encodenow returns aLengthErrorwhen the headers and payload together don't fit in the prelude's 32-bit total length field, instead of writing a truncated length. The limit is the wire format's, added asmaxMsgLen(math.MaxUint32), and the check is done in 64-bit arithmetic so it holds on 32-bit platforms too.The same change will follow in aws-sdk-go-v2 for its copy of this package in
aws/protocol/eventstreamBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.