[
https://issues.apache.org/jira/browse/THRIFT-1101?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Bryan Duxbury closed THRIFT-1101.
---------------------------------
Resolution: Fixed
Fix Version/s: 0.7
Assignee: Bryan Duxbury
I just committed a fix to this in both the Binary and Compact protocols. Thanks
for bringing it to my attention, Dave.
> bytebuffer length calculation in TBinaryProtocol writeBinary
> ------------------------------------------------------------
>
> Key: THRIFT-1101
> URL: https://issues.apache.org/jira/browse/THRIFT-1101
> Project: Thrift
> Issue Type: Bug
> Components: Java - Library
> Reporter: Dave
> Assignee: Bryan Duxbury
> Fix For: 0.7
>
>
> 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.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira