Skip to content

Apache Lucene open-source search software

add missing safety check

Robert Muir4b95522725ad
diff --git a/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java b/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java
index 3f7ea846dd9..0b1a56263ab 100644
--- a/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java
+++ b/lucene/core/src/java/org/apache/lucene/store/CompoundFileDirectory.java
@@ -141,6 +141,9 @@ public final class CompoundFileDirectory extends BaseDirectory {
fileEntry.offset = entriesStream.readLong();
fileEntry.length = entriesStream.readLong();
}
+ if (entriesStream.getFilePointer() != entriesStream.length()) {
+ throw new CorruptIndexException("did not read all bytes from file \"" + entriesFileName + "\": read " + entriesStream.getFilePointer() + " vs size " + entriesStream.length() + " (resource: " + entriesStream + ")");
+ }
return mapping;
} catch (IOException ioe) {
priorE = ioe;