apache / apache/arrow-java

[Java][JDBC] ClobConsumer writes past VarCharVector data buffer for large CLOBs

Ouverte Adaptée aux débutants
#1,230 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Java
Étoiles
94
Forks
152
Merge moyen
3 j 16 h
PR mergées (30 j)
11

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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Localisez ClobConsumer et comparez sa protection contre l’agrandissement du tampon de données de VarCharVector avec la vérification correspondante de BinaryConsumer. Reproduisez le problème avec un CLOB dont les données UTF-8 dépassent l’allocation initiale, puis vérifiez que les données cumulées du CLOB ou du lot n’altèrent pas le tampon d’offset et peuvent être relues correctement.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
java
Domaine
backend, database
Type d'issue
Bug
Difficulté
2/5
Temps estimé
1-3 heures
Activité
Calme
Clarté
Clairement spécifiée
Accessibilité débutants
78/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.