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


##########
lang/c/src/codec.c:
##########
@@ -483,11 +609,41 @@ static int decode_lzma(avro_codec_t codec, void * data, 
int64_t len)
 
                codec->used_size = write_pos;
 
-               // If it ran out of space to decode, give it more!!
-               // It will continue where it left off because of read_pos and 
write_pos.
+               // Reject a block that decompresses to more than the allowed 
maximum,
+               // to guard against unbounded allocation from a high-ratio 
block.

Review Comment:
   `decode_lzma` passes the `int64_t len` parameter directly to 
`lzma_raw_buffer_decode` as the input size. Since liblzma takes a `size_t` for 
that argument, a negative (or >SIZE_MAX) `len` passed to `avro_codec_decode()` 
would wrap/truncate during implicit conversion and could make the decoder read 
an unintended amount of input. Add an explicit range check and cast once to a 
local `size_t` before calling into liblzma.



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