Skip to content

Fix/eventstream prelude length check - #755

Merged
Madrigal merged 2 commits into
mainfrom
fix/eventstream-prelude-length-check
Nov 23, 2026
Merged

Madrigal merged 2 commits into
mainfrom
fix/eventstream-prelude-length-check

Conversation

@Madrigal

@Madrigal Madrigal commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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 LengthError before any headers or payload are read. There is still no upper limit on message size, just the actual size of the data type

TestDecodeLimits now 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-0x01 input declared a headers length equal to the total length, which is now a length error.

On the encoding side, Encode now returns a LengthError when 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 as maxMsgLen (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/eventstream

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Madrigal
Madrigal marked this pull request as ready for review November 23, 2026 17:54
@Madrigal
Madrigal requested review from a team as code owners November 23, 2026 17:54
@Madrigal Madrigal assigned Madrigal and wty-Bryant and unassigned Madrigal Nov 23, 2026
@Madrigal
Madrigal merged commit 0817dc1 into main Nov 23, 2026
15 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.

2 participants