Copilot commented on code in PR #3851:
URL: https://github.com/apache/avro/pull/3851#discussion_r3564680847
##########
lang/ruby/lib/avro/data_file.rb:
##########
@@ -339,6 +372,13 @@ def codec_name; 'snappy'; end
def decompress(data)
load_snappy!
+ # The Snappy block header declares the uncompressed length as a varint;
+ # reject an over-large block before allocating for it.
+ limit = DataFile.max_decompress_length
+ declared = self.class.snappy_declared_length(data)
+ if declared && declared > limit
+ raise DecompressionSizeError, "Decompressed block size exceeds the
maximum allowed of #{limit} bytes"
+ end
Review Comment:
`SnappyCodec#decompress` skips the size guard when `snappy_declared_length`
returns `nil` (unparseable header), which can allow a malformed Snappy block to
bypass the pre-allocation limit and rely on `Snappy.inflate` to handle it. For
a hardening limit, this should fail closed: treat an unparseable header as an
error before attempting decompression.
--
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]