Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ public ByteBuffer readBinary() throws TException {
if (length == 0) {
return EMPTY_BUFFER;
}
getTransport().checkReadBytesAvailable(length);
checkStringReadLength(length);
if (trans_.getBytesRemainingInBuffer() >= length) {
ByteBuffer bb = ByteBuffer.wrap(trans_.getBuffer(), trans_.getBufferPosition(), length);
trans_.consumeBuffer(length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ public void testCompactProtocol_stringLengthLimitEnforcedInFastPath() throws Exc
"TCompactProtocol stringLengthLimit must reject oversized strings in fast path");
}

@Test
public void testCompactProtocol_stringLengthLimitEnforcedForBinary() throws Exception {
// binary uses the same varint-length encoding as a string on the wire
byte[] buf = encodeCompactString(repeat('A', 100));
TMemoryInputTransport transport = new TMemoryInputTransport(buf);

TCompactProtocol proto = new TCompactProtocol(transport, 10L, -1L);

assertThrows(
TProtocolException.class,
proto::readBinary,
"TCompactProtocol stringLengthLimit must also gate readBinary, not just readString");
}

@Test
public void testConsumeBuffer_decrementsRemainingMessageSize() throws Exception {
// 20-byte transport; updateKnownMessageSize sets remainingMessageSize = 20
Expand Down
Loading