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.
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