Copilot commented on code in PR #3864:
URL: https://github.com/apache/avro/pull/3864#discussion_r3566793106
##########
lang/perl/lib/Avro/BinaryDecoder.pm:
##########
@@ -350,7 +559,13 @@ sub decode_union {
sub skip_fixed {
my $class = shift;
my ($schema, $reader) = @_;
- $reader->seek($schema->size, 0);
+ # Skip the fixed-size payload relative to the current position (SEEK_CUR);
+ # whence 0 (SEEK_SET) would incorrectly seek to the absolute offset. A
+ # failed seek is treated as fatal.
+ unless ($reader->seek($schema->size, 1)) {
+ throw Avro::Schema::Error::Parse(
+ "Failed to skip " . $schema->size . " bytes");
+ }
Review Comment:
skip_fixed() uses seek() to skip over the fixed payload, but seek past EOF
can silently succeed on many handles (the same issue addressed in skip_bytes
via _ensure_available). This can allow truncated inputs to be silently skipped
and later decoded as zeros instead of failing. Consider mirroring skip_bytes by
validating available bytes (when the reader can report them) before seeking.
--
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]