iemejia commented on code in PR #3864:
URL: https://github.com/apache/avro/pull/3864#discussion_r3567357053


##########
lang/perl/lib/Avro/BinaryDecoder.pm:
##########
@@ -380,6 +626,12 @@ sub unsigned_varint {
     my $more;
     my $shift = 0;
     do {
+        # A 64-bit value uses at most 10 bytes (shifts 0..63); reject an 
overlong
+        # varint rather than reading an unbounded continuation chain and 
letting
+        # $shift overflow into a garbage value.
+        if ($shift >= 70) {
+            throw Avro::Schema::Error::Parse("Varint is too long");
+        }
         $reader->read(my $buf, 1);
         my $byte = ord $buf;

Review Comment:
   Fixed — `unsigned_varint` now checks the `$reader->read` return value and 
throws a parse error on a short/EOF read, instead of letting `ord ""` == 0 
silently decode truncated input as a valid 0 byte.



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