Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
4.2
-
None
Description
The LengthDelimitedEncoder class fails to deliver contents that are larger than 2GB, because the write(final ByteBuffer src) method incorrectly calculates
int lenRemaining = (int) (this.contentLength - this.len);
For example, if this.contentLength is 3,000,000,000 and this.len is 0, then lenRemaining will be negative and things will go wrong in the process.
Changing the line to
long lenRemaining = this.contentLength - this.len;
will fix this bug (maybe src.remaining() needs to be casted to (long) in the following if statement).