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


##########
lang/perl/lib/Avro/BinaryDecoder.pm:
##########
@@ -132,10 +132,109 @@ sub decode_bytes {
     my $class = shift;
     my $reader = pop;
     my $size = decode_long($class, undef, undef, $reader);
+    if ($size < 0) {
+        throw Avro::Schema::Error::Parse(
+            "Invalid negative bytes/string length: $size");
+    }
+    _ensure_available($reader, $size);
     $reader->read(my $buf, $size);

Review Comment:
   `decode_bytes` does not verify that `read` actually returned `$size` bytes, 
so truncated input (or an I/O short read) can silently return a shorter buffer 
and leave the decoder misaligned. Also, `skip_bytes` (used by `skip_string` 
during schema resolution) currently seeks without validating the decoded 
length; negative lengths and short/truncated inputs should be rejected 
consistently to avoid corrupting subsequent decoding when skipping fields.



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