jacek-lewandowski commented on code in PR #2368:
URL: https://github.com/apache/cassandra/pull/2368#discussion_r1209767983


##########
src/java/org/apache/cassandra/io/util/TrackedDataInputPlus.java:
##########
@@ -129,22 +156,34 @@ public String readUTF() throws IOException
 
     public int readUnsignedByte() throws IOException
     {
+        checkCanRead(1);
         int i = source.readUnsignedByte();
         bytesRead += 1;
         return i;
     }
 
     public int readUnsignedShort() throws IOException
     {
+        checkCanRead(2);
         int i = source.readUnsignedShort();
         bytesRead += 2;
         return i;
     }
 
     public int skipBytes(int n) throws IOException
     {
-        int skipped = source.skipBytes(n);
+        int skipped = source.skipBytes(limit < 0 ? n : (int) Math.min(limit - 
bytesRead, n));
         bytesRead += skipped;
         return skipped;
     }
+
+    @Inline
+    private void checkCanRead(int size) throws IOException
+    {
+        if (limit >= 0 && bytesRead + size > limit)

Review Comment:
   Yes, we always encode at least a flag



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to