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

   ## 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.
   
   This validates 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, or by setting
   `$Avro::BinaryDecoder::MAX_COLLECTION_ITEMS`. Exceeding it throws
   `Avro::BinaryDecoder::Error::CollectionSize`.
   
   This is part of the umbrella issue AVRO-4277.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
   - Added `lang/perl/t/06_bin_decode_limits.t` 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: `cd lang/perl && prove -Ilib t/`
   
   ## 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