jbonofre opened a new issue, #1462:
URL: https://github.com/apache/arrow-java/issues/1462

   ### Describe the bug
   
   Follow-up to #1421 / #1422. A few other values read from IPC and C Data 
input are used before they are checked, and some error paths leak the message 
body.
   
   - **C Data:** `ArrayImporter` reads `n_children` and `n_buffers` child and 
buffer pointers before comparing those counts with what the type expects. A 
huge count sizes a `long[]` from it, which throws `OutOfMemoryError` (an 
`Error`, so it is not wrapped like other import failures) or reads past the end 
of the pointer array.
   - **IPC:** `MessageSerializer.deserializeRecordBatch` copies 
`variadicBufferCounts` without checking them. `VectorLoader` casts each count 
to `int` and uses it to size an `ArrayList`, so a count like `1_000_000_000` 
allocates a huge list, and a count above `INT_MAX` is truncated and assigns 
buffers to the wrong fields.
   - **IPC leaks:**
     - `deserializeMessageBatch` throws after reading the body, without 
releasing it, when the message is too large, has an unsupported metadata 
version, or has an unexpected header type.
     - The `ArrowBlock` variants of `deserializeRecordBatch` and 
`deserializeDictionaryBatch` leak the block buffer when the read is short or 
the metadata is malformed.
   - **JSON:** `JsonFileReader.read()` calls `setRowCount(count)` before 
reading the columns, so the vectors are first allocated for the batch count 
even if the columns are then rejected.
   
   ### Expected behavior
   
   Counts are checked before they size an allocation or a read. Rejected 
messages release everything they allocated.
   
   ### Component(s)
   
   Java
   


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