From: David Reiss Date: Tue, 9 Mar 2010 05:19:11 +0000 (+0000) Subject: THRIFT-657. java: Detect negative length in TBinaryProtocol X-Git-Tag: 0.3.0~101 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=487fd2e0435db0326a60821bcc96e56fa2eee711;p=common%2Fthrift.git THRIFT-657. java: Detect negative length in TBinaryProtocol git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920658 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java b/lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java index 83c85e16..16c7567c 100644 --- a/lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java +++ b/lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java @@ -365,6 +365,9 @@ public class TBinaryProtocol extends TProtocol { } protected void checkReadLength(int length) throws TException { + if (length < 0) { + throw new TException("Negative length: " + length); + } if (checkReadLength_) { readLength_ -= length; if (readLength_ < 0) {