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


##########
lang/c/src/codec.c:
##########
@@ -483,11 +598,38 @@ 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.
+               if ((int64_t) write_pos > max_len) {
+                       avro_set_error("Decompressed block size exceeds the 
maximum allowed of %lld bytes",
+                                      (long long) max_len);
+                       return 1;
+               }

Review Comment:
   Fixed — the guard now compares `write_pos > (size_t) max_len` (max_len is >= 
0 and clamped to SIZE_MAX) instead of narrowing write_pos to int64_t, so it 
can't wrap negative and bypass the cap.



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