ArrowFlightJdbcArray.getArray(index, count) can read past the end of the array slice
- 主要語言
- Java
- 星號
- 94
- 分支
- 152
- 平均合併
- 3 天 16 小時
- 30 天內合併 PR
- 11
描述
`ArrowFlightJdbcArray.checkBoundaries` validates the caller-supplied index against `startOffset + valuesCount`:
```java
private void checkBoundaries(long index, int count) {
if (index < 0 || index + count > this.startOffset + this.valuesCount) {
throw new ArrayIndexOutOfBoundsException();
}
}
```
but `index` is relative to the start of the array; both call sites add `startOffset` to it only afterwards, e.g.
```java
checkBoundaries(index, count);
return getArrayNoBoundCheck(
this.dataVector, LargeMemoryUtil.checkedCastToInt(this.startOffset + index), count);
```
So the accepted range is too large by exactly `startOffset` elements, and `getArray(index, count)` / `getResultSet(index, count)` will read up to that far past the end of the row's slice.
`AbstractArrowFlightJdbcListVectorAccessor` builds these with the offsets of the list element being read, so any row of a list column that does not start at child offset 0 is affected. Reading within the element count the driver itself advertises then returns values belonging to other rows of the shared child vector, and past the child vector's `valueCount` it returns whatever is in allocated-but-unwritten memory.
Reproducer against an `IntVector` of 127 values, with an array covering elements 5..7:
```java
ArrowFlightJdbcArray array = new ArrowFlightJdbcArray(dataVector, 5, 3);
array.getArray(1, 3); // accepted; returns elements 6, 7, 8 — element 8 is outside the array
```
Every existing test constructs the array with `startOffset` 0, where the wrong bound happens to coincide with the correct one, which is why this is not currently caught.
貢獻指南
研究方向
從 ArrowFlightJdbcArray.checkBoundaries 開始,檢查 getArray(index, count) 和 getResultSet(index, count) 兩者的呼叫點。使用非零 startOffset 新增回歸測試,例如使用提供的 IntVector slice,並執行現有的 ArrowFlightJdbcArray 測試;完成的條件是請求無法讀取超出陣列 slice 的範圍。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java
- 領域
- database
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 冷清
- 描述清晰度
- 描述清楚
- 新手友好度
- 78/100