[
https://issues.apache.org/jira/browse/ARROW-17338?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated ARROW-17338:
-----------------------------------
Labels: pull-request-available (was: )
> [Java] The maximum request memory of BaseVariableWidthVector should limit to
> Interger.MAX_VALUE
> -----------------------------------------------------------------------------------------------
>
> Key: ARROW-17338
> URL: https://issues.apache.org/jira/browse/ARROW-17338
> Project: Apache Arrow
> Issue Type: Bug
> Components: Java
> Reporter: Xianyang Liu
> Priority: Major
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The following code of `BaseVariableWidthVector.handleSafe` could fail to
> relocated because of int overflow and then led to `IndexOutOfBoundsException`
> when we put the data into the vector.
> ```java
> protected final void handleSafe(int index, int dataLength) {
> while (index >= getValueCapacity()) {
> reallocValidityAndOffsetBuffers();
> }
> final int startOffset = lastSet < 0 ? 0 : getStartOffset(lastSet + 1);
> // Here, the startOffset + dataLength could overflow
> while (valueBuffer.capacity() < (startOffset + dataLength)) {
> reallocDataBuffer();
> }
> }
> ```
> The offset width of `BaseVariableWidthVector` is 4, while the maximum memory
> allocation is Long.MAX_VALUE. This makes the memory allocation check invalid.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)