From 67f71d453d281d6b6db230fbd914fbe36220a9cb Mon Sep 17 00:00:00 2001 From: Michael Sokolov Date: Thu, 4 Feb 2021 13:52:13 -0500 Subject: [PATCH] LUCENE-9715: fix int overflow in Lucene90VectorReader --- .../lucene/codecs/lucene90/Lucene90VectorReader.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90VectorReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90VectorReader.java index 91c49e5851a..370c9f015bc 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90VectorReader.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90VectorReader.java @@ -359,14 +359,14 @@ public final class Lucene90VectorReader extends VectorReader { @Override public float[] vectorValue() throws IOException { - dataIn.seek(ord * byteSize); + dataIn.seek((long) ord * byteSize); dataIn.readLEFloats(value, 0, value.length); return value; } @Override public BytesRef binaryValue() throws IOException { - dataIn.seek(ord * byteSize); + dataIn.seek((long) ord * byteSize); dataIn.readBytes(byteBuffer.array(), byteBuffer.arrayOffset(), byteSize, false); return binaryValue; } @@ -440,7 +440,7 @@ public final class Lucene90VectorReader extends VectorReader { @Override public float[] vectorValue(int targetOrd) throws IOException { - dataIn.seek(targetOrd * byteSize); + dataIn.seek((long) targetOrd * byteSize); dataIn.readLEFloats(value, 0, value.length); return value; } @@ -452,8 +452,7 @@ public final class Lucene90VectorReader extends VectorReader { } private void readValue(int targetOrd) throws IOException { - long offset = targetOrd * byteSize; - dataIn.seek(offset); + dataIn.seek((long) targetOrd * byteSize); dataIn.readBytes(byteBuffer.array(), byteBuffer.arrayOffset(), byteSize); } }