Arawoof06 opened a new pull request, #1505:
URL: https://github.com/apache/arrow-java/pull/1505

   ## What's Changed
   
   `BaseFixedWidthVector.copyFrom` copied `typeWidth` bytes with a raw 
`MemoryUtil.copyMemory`, so the source range was never checked against the 
source data buffer. `loadFieldBuffers` does not compare the data buffer length 
with the field node length, and full validation is off by default in 
`ArrowReader`, so an IPC batch or dictionary that declares 16 Int values with a 
4-byte data buffer loads without error. `get(8)` on that vector throws 
`IndexOutOfBoundsException`, but `copyFrom`/`copyFromSafe` (also reached 
through `TransferPair.copyValueSafe`, e.g. from `DictionaryEncoder.decode` and 
the struct/list/union `copyFrom` paths) copies whatever native memory follows 
the buffer into the target vector, with bounds checking enabled.
   
   The copy now goes through `ArrowBuf.setBytes(index, src, srcIndex, length)`, 
which always checks the source range and checks the destination when bounds 
checking is on, matching the variable-width `copyFrom`, which already uses the 
checked `getBytes`. The validity bit is set after the copy, so a rejected copy 
leaves the target slot null.
   
   The new test in `TestCopyFrom` loads an `IntVector` with a short data buffer 
and expects `IndexOutOfBoundsException` from both `copyFrom` and 
`copyFromSafe`. Before the change, the same setup copied the `0x41414141` 
written just past the slice into the target. The `vector` and `algorithm` test 
suites pass.
   


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