nats-io / nats-server

High-Performance server for NATS.io, the cloud and edge native messaging system.
https://nats.io
Apache License 2.0
16k stars 1.41k forks source link

Refactor encoding replicated stream messages to properly enforce framing #6052

Closed neilalexander closed 3 weeks ago

neilalexander commented 3 weeks ago

This PR fixes two bugs in encodeStreamMsgAllowCompress:

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