iemejia opened a new pull request, #3848:
URL: https://github.com/apache/avro/pull/3848

   ## What is the purpose of the change
   
   When decoding an array or map, the block count is read from the input and 
drives
   allocation of the resulting collection. A very large or malformed block count
   (for example from truncated or hostile input) could request an unbounded
   allocation, since items such as `null` occupy no bytes on the wire.
   
   `read_array_value()` / `read_map_value()` now validate the block count — per
   block and cumulatively — against a configurable maximum before allocating,
   mirroring the Java SDK's collection item limit
   (`org.apache.avro.limits.collectionItems.maxLength`, AVRO-3819). The limit
   defaults to `2^31 - 8` items and can be overridden with the
   `AVRO_MAX_COLLECTION_ITEMS` environment variable. Exceeding it fails decoding
   with `EINVAL` and a descriptive error.
   
   This is part of the umbrella issue AVRO-4277.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
   - Added `lang/c/tests/test_avro_4279.c` (registered in 
`tests/CMakeLists.txt`)
     covering: a single block count above the limit (array and map), a 
cumulative
     limit across blocks, a negative block count bounded by its absolute value, 
and
     a within-limit collection still decoding correctly.
   - Run: `ctest -R test_avro_4279` (also passes under the valgrind memcheck 
variant)
   
   ## Documentation
   
   - Does this pull request introduce a new feature? (no — hardening/robustness)
   - If yes, how is the feature documented? (not applicable; the new
     `AVRO_MAX_COLLECTION_ITEMS` environment variable is documented in code 
comments)
   


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