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


##########
lang/c/src/codec.c:
##########
@@ -331,6 +418,15 @@ static int decode_deflate(avro_codec_t c, void * data, 
int64_t len)
        {
                err = inflate(s, Z_FINISH);
 
+               // Reject a block that decompresses to more than the allowed 
maximum,
+               // to guard against unbounded allocation from a high-ratio 
block.
+               if ((int64_t) s->total_out > max_len) {
+                       inflateEnd(s);
+                       avro_set_error("Decompressed block size exceeds the 
maximum allowed of %lld bytes",
+                                      (long long) max_len);
+                       return 1;
+               }

Review Comment:
   Fixed — the over-limit rejection paths now call `inflateReset(s)` instead of 
`inflateEnd(s)`, so the codec's zlib stream stays allocated and reusable for 
subsequent avro_codec_decode() calls (we're only refusing the oversized output, 
the stream itself is fine).



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