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

   # Which issue does this PR close?
   
   - Closes #11943.
   
   # Rationale for this change
   
   `validate` only requires a minimum size for fixed-width buffers, but 
`typed_buffer` typed the whole buffer with `Buffer::typed_data`, which asserts 
that the length is a multiple of the element width. A buffer with a few 
trailing bytes, for example from a corrupted IPC message, therefore panicked 
during validation.
   
   # What changes are included in this PR?
   
   `typed_buffer` types only the `required_len` bytes it reads, and returns an 
error instead of asserting when they are misaligned. `validate` already checks 
alignment before reaching `typed_buffer`, so that error is for 
`validate_values` called on unchecked data.
   
   # Are these changes tested?
   
   Yes: an `ArrayData` with a 14-byte `Utf8` offsets buffer now validates, and 
the IPC reader reads a hand-built batch with such a buffer. Both tests panic 
without the change.
   
   # Are there any significant user-facing changes?
   
   No.
   
   AI usage: the bug was found and reproduced with Claude Code, which also 
drafted the change, the tests and this description. I reviewed the change, ran 
both tests with and without the fix, and checked it against the original 
reproduction: the two byte positions that panicked are read without error after 
the change.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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