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


##########
lang/perl/lib/Avro/BinaryDecoder.pm:
##########
@@ -124,6 +124,10 @@ sub skip_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");
+    }
     $reader->seek($size, 0);

Review Comment:
   `skip_bytes` seeks using `SEEK_SET` (whence `0`), which moves the reader to 
absolute offset `$size` rather than skipping forward from the current position. 
This will misalign decoding whenever `skip_bytes`/`skip_string` are used after 
reading prior fields (e.g., during schema projection or skipping unknown 
fields). Use `SEEK_CUR` so the skip is relative to the current offset.



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