ArrowFlightJdbcArray.getArray(index, count) can read past the end of the array slice

Aberta Para iniciantes
#1,236 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
78/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Pouca atividade
Stack de tecnologia
java
Domínio
database

Direção de pesquisa

Comece em ArrowFlightJdbcArray.checkBoundaries e inspecione os call sites de getArray(index, count) e getResultSet(index, count). Adicione um teste de regressão usando um startOffset diferente de zero, como o slice de IntVector fornecido, e execute os testes existentes de ArrowFlightJdbcArray; considera-se concluído quando as solicitações não puderem ler além do slice do array.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

ArrowFlightJdbcArray.checkBoundaries validates the caller-supplied index against startOffset + valuesCount:

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.

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:

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.

Linguagem predominante
Java
Estrelas
95
Forks
154
Merge médio
2d 16h
PRs com merge (30d)
9

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de apache/arrow-java

Todas as issues de apache/arrow-java

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.