Copilot commented on code in PR #3861:
URL: https://github.com/apache/avro/pull/3861#discussion_r3568126296


##########
lang/py/avro/io.py:
##########
@@ -383,8 +436,15 @@ def skip_int(self) -> None:
 
     def skip_long(self) -> None:
         b = ord(self.read(1))
+        count = 1
         while (b & 0x80) != 0:
+            # A 64-bit varint is at most 10 bytes; reject an overlong chain so 
a
+            # skipped long can't force scanning unbounded input (read_long caps
+            # the same way).
+            if count >= 10:
+                raise avro.errors.InvalidAvroBinaryEncoding("Varint is too 
long")
             b = ord(self.read(1))
+            count += 1
 

Review Comment:
   `skip_long()` now caps the number of bytes read, but it still doesn’t 
enforce the same 64-bit varint validity as `read_long()` (specifically the 
“10th byte must not carry payload bits above bit 63” check). That means 
malformed 10-byte varints that `read_long()` would reject can still be silently 
accepted when skipping (e.g., negative-block byte sizes in 
`read_array`/`read_map`). Consider reusing `read_long()` here so skip paths 
reject the same invalid encodings.



-- 
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]

Reply via email to