Rich-T-kid commented on PR #12340:
URL: https://github.com/apache/arrow-rs/pull/12340#issuecomment-7020558854

   I audited these crates for realistic externally controlled arithmetic rather 
than replacing arithmetic mechanically.
   
   The changed callsites are worth guarding because their operands cross an 
external boundary and feed a narrow representation, allocation, or slice:
   
   - `arrow-integration-testing`: `RecordBatch::num_rows()` is `usize`, while 
Flight exposes `total_records` as `i64`. Both the per-batch conversion and the 
aggregate can overflow independently.
   - `arrow-csv`: caller-provided row limits and schema column counts are 
multiplied before `Vec::resize`; this is especially reachable on 32-bit targets 
and previously overflowed before allocation.
   - `arrow-integration-test`: integration JSON directly supplies narrow 
integer values, offsets, sizes, and fixed-width lengths. Unchecked casts 
silently changed the represented value, while `offset + size` and Decimal256 
copies could panic before validation.
   - `arrow-pyarrow`: Python controls `__len__`, and that value was passed 
directly to `Vec::with_capacity`. A bad length hint could turn malformed 
external input into a Rust allocation panic.
   
   I left arithmetic alone where it is dominated by an existing slice or buffer 
length, uses fixed small enum ranges, is a loop counter bounded by an allocated 
collection, or is an intentional physical/logical integer reinterpretation. 
Those cases do not have the same overflow path and changing them would make 
this a mechanical audit rather than a targeted one.


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