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


##########
lang/c++/impl/DataFile.cc:
##########
@@ -627,12 +679,30 @@ void DataFileReaderBase::readDataBlock() {
 
             const uint8_t *data;
             size_t len;
+            const size_t maxLength = maxDecompressLength();

Review Comment:
   In the deflate path, `maxLength` can be configured up to `size_t` max, but 
zlib’s `z_stream::total_out` is a `uLong` (32-bit on some platforms, e.g. 
Windows). If `AVRO_MAX_DECOMPRESS_LENGTH` is set above 
`std::numeric_limits<uLong>::max()`, `zs.total_out` can overflow, which would 
make buffer indexing (`uncompressed.data() + zs.total_out`) incorrect and risks 
memory corruption. Clamp the effective limit for the deflate/zlib branch to 
what zlib counters can represent (or fail early) to keep indexing safe across 
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