ToniAdreal opened a new pull request, #12429:
URL: https://github.com/apache/arrow-rs/pull/12429

   Fixes #12409.
   
   `FixedSizeBinaryArray::try_new` accepted a values buffer longer than `len * 
value_size` and kept the extra bytes, so `value_data()`, `values()`, and 
`into_parts()` all exposed trailing bytes. The root cause is integer division 
in the length check: `values.len() / value_size == len` passes when the buffer 
has a remainder (10 bytes with value_size 3 gives len 3, with 1 byte left 
over). The same overlong buffer then leaked into builders through 
`append_array`, which copied `value_data()` verbatim.
   
   Changes:
   
   - `FixedSizeBinaryArray::try_new_with_len` now truncates the buffer with 
`slice_with_length(0, len * value_size)` after validation, zero copy. This 
covers `try_new`, `new`, `try_new_with_len`, and the `force_validate` path, and 
fixes all three leak surfaces at once. This matches the existing 
`From<ArrayData>` behavior, which already truncates the same way.
   - `FixedSizeBinaryBuilder::append_array` now copies only `len * 
value_length` bytes, so an unchecked array carrying trailing bytes cannot 
pollute the builder.
   - Three regression tests: `try_new` and `try_new_with_len` with a 10 byte 
buffer and value_size 3 assert `value_data()`, `values()`, and `into_parts()` 
all report 9 bytes; `append_array` from an unchecked 10 byte array asserts the 
builder holds 9 bytes and the finished array reports 9.
   
   Verification:
   
   - Reproduction test (issue example, 3 values of size 3 in a 10 byte buffer) 
failed before the fix (`value_data().len()` was 10, expected 9) and passes 
after.
   - `cargo test -p arrow-array --lib fixed_size_binary`: 45 passed, 0 failed.
   - `cargo test -p arrow-array --lib`: 765 passed, 0 failed, 1 filtered out. 
The filtered test is `test_gc_huge_array`, which the 6 GB dev cell OOM-kills 
(SIGKILL, unrelated to this change); CI should run it.
   - `cargo clippy -p arrow-array`: clean, no warnings.
   
   AI assistance disclosure: This PR was prepared with AI assistance (Muse). I 
reviewed the diff line by line, I understand the change, and I ran the tests 
listed above.
   


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