THRIFT-657. java: Detect negative length in TBinaryProtocol
authorDavid Reiss <dreiss@apache.org>
Tue, 9 Mar 2010 05:19:11 +0000 (05:19 +0000)
committerDavid Reiss <dreiss@apache.org>
Tue, 9 Mar 2010 05:19:11 +0000 (05:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920658 13f79535-47bb-0310-9956-ffa450edef68

lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java

index 83c85e1..16c7567 100644 (file)
@@ -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) {