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


##########
lang/c/src/codec.c:
##########
@@ -141,12 +188,29 @@ static int decode_snappy(avro_codec_t c, void * data, 
int64_t len)
 {
         uint32_t crc;
         size_t outlen;
+        int64_t max_len = avro_max_decompress_length();
+
+        /* The block carries a trailing 4-byte CRC; a length below that is
+         * malformed and would underflow len - 4. */
+        if (len < 4) {
+                avro_set_error("Snappy block too small (%lld bytes), expected 
at least 4",
+                               (long long) len);

Review Comment:
   Fixed — decode_snappy now rejects `len - 4 > SIZE_MAX` and uses a single 
`size_t inlen = (size_t)(len - 4)` for both 
snappy_uncompressed_length/snappy_uncompress and the trailing-CRC offset, so no 
truncation occurs on narrow-size_t platforms.



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