Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
In TBinaryProtocol writeBinary, the length calculation appears incorrect:
length = bin.limit() - bin.position() - bin.arrayOffset();
This subtraction of arrayOffset can cause a negative length on a sliced buffer. For example:
ByteBuffer b = ByteBuffer.allocate(15);
b.put("1234567890".getBytes());
ByteBuffer b2 = b.slice();
b2.put("testx".getBytes());
b2.rewind();
So b2's length is lim-pos-offset = 5-0-10 = -5.
I believe we just want lim-pos.