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

   ## Summary
   
   Fix signed integer overflow in `BinaryDecoder::doDecodeItemCount()` when the 
decoded block count equals `INT64_MIN`.
   
   ## Problem
   
   The existing negation idiom `-(result + 1) + 1` still overflows on the final 
`+ 1` when `result == INT64_MIN` (since `-INT64_MIN` is not representable in 
`int64_t`). This is undefined behavior in C++ and could result in the decoder 
returning `2^63` as the item count for both arrays and maps.
   
   ## Fix
   
   - Add an explicit guard: if `result == INT64_MIN`, throw an `Exception` 
immediately.
   - For all other negative values, use simple `-result` which is well-defined.
   
   ## Tests
   
   Added two new test cases:
   - `testArrayInt64MinBlockCount` — verifies `arrayStart()` throws on a 
zigzag-encoded `INT64_MIN` block count.
   - `testMapInt64MinBlockCount` — verifies `mapStart()` throws on the same 
input.
   
   This is the C++ counterpart to the C fix in commit 271de63230.


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