Copilot commented on code in PR #3864:
URL: https://github.com/apache/avro/pull/3864#discussion_r3565740502
##########
lang/perl/lib/Avro/BinaryDecoder.pm:
##########
@@ -124,18 +124,130 @@ sub skip_bytes {
my $class = shift;
my $reader = pop;
my $size = decode_long($class, undef, undef, $reader);
- $reader->seek($size, 0);
+ if ($size < 0) {
+ throw Avro::Schema::Error::Parse(
+ "Invalid negative bytes/string length: $size");
+ }
+ # Skip forward by $size bytes relative to the current position
+ # (SEEK_CUR); whence 0 (SEEK_SET) would incorrectly seek to the
+ # absolute offset $size.
+ $reader->seek($size, 1);
return;
Review Comment:
`skip_bytes` can silently succeed even when the declared length exceeds the
bytes actually available (seek beyond EOF is allowed on many handles), which
can cause subsequent decoding to read EOF as zeros and return incorrect data
instead of failing on truncated input. Consider validating against
`_bytes_remaining` when available and treating a failed `seek` as a hard error.
--
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]