Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor encoding replicated stream messages to properly enforce framing #6052

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

neilalexander
Copy link
Member

This PR fixes two bugs in encodeStreamMsgAllowCompress:

  • The boundary lengths could have overflowed when casting potentially large values down to uint16 or uint32 and we wouldn't have noticed;
  • We would then copy in the subject/reply/header/msg with the original length regardless, not the overflowed length, meaning the decoding side would have the wrong boundaries.

Now we will correctly calculate the bounds, avoiding overflows, and only append as many bytes as we clipped down to.

Signed-off-by: Neil Twigg neil@nats.io

@neilalexander neilalexander marked this pull request as ready for review October 29, 2024 10:55
@neilalexander neilalexander requested a review from a team as a code owner October 29, 2024 10:55
server/jetstream_cluster.go Show resolved Hide resolved
server/jetstream_cluster.go Show resolved Hide resolved
server/jetstream_cluster.go Outdated Show resolved Hide resolved
@derekcollison derekcollison self-requested a review October 29, 2024 11:16
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekcollison derekcollison merged commit 06e5aa2 into main Oct 29, 2024
5 checks passed
@derekcollison derekcollison deleted the neil/encodestreammsg branch October 29, 2024 11:58
neilalexander added a commit that referenced this pull request Oct 29, 2024
Includes the following:

- #5115
- #6019
- #6039
- #6034
- #6043
- #6042
- #6047
- #6049
- #6050 
- #6052
- #6053

Signed-off-by: Neil Twigg <neil@nats.io>
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