[Java][JDBC] ClobConsumer writes past VarCharVector data buffer for large CLOBs
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Locate ClobConsumer and compare its VarCharVector data-buffer growth guard with the sibling BinaryConsumer check. Reproduce with a CLOB whose UTF-8 data exceeds the initial allocation, then verify that cumulative CLOB or batch data does not corrupt the offset buffer and can be read back successfully.
Written by the indexing model from the issue text.
Description
ClobConsumer copies CLOB data into the VarCharVector data buffer with MemoryUtil.copyToMemory at offset startIndex + totalBytes, but the buffer-growth guard checks dataBuffer.writerIndex() + bytes.length > dataBuffer.capacity(). copyToMemory never advances writerIndex(), and nothing else does either, so it stays at 0 and the guard only ever checks that a single chunk fits at offset 0. Once the cumulative bytes of a CLOB (or a batch of CLOB rows) exceed the initial data-buffer allocation of about 32 KB, reallocDataBuffer() is never called and copyToMemory, which performs no ArrowBuf bounds checking, writes past the allocation into adjacent off-heap memory.
The sibling BinaryConsumer uses the correct check: while (vector.getDataBuffer().capacity() < (startOffset + dataLength + read)).
To reproduce, consume a single CLOB whose UTF-8 length exceeds the initial data buffer (for example INITIAL_VALUE_ALLOCATION * 8 * 4 characters). The out-of-bounds write corrupts the adjacent offset buffer, and reading the value back throws NegativeArraySizeException.
- Dominant language
- Java
- Stars
- 95
- Forks
- 154
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/arrow-java
-
Type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/arrow-java#1300 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
apache/arrow-java#1261 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/arrow-java#1236 ·
-
Type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
apache/arrow-java#1205 ·
-
Type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
apache/arrow-java#1196 · 1 comment ·
All issues in apache/arrow-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100