mirror of https://github.com/apache/lucene.git
LUCENE-5617: don't rely on directory metadata for stored fields 'maxpointer', change to hard check
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1588498 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
07470a07f9
commit
b9a22bb5db
|
@ -118,12 +118,12 @@ public final class CompressingStoredFieldsReader extends StoredFieldsReader {
|
||||||
assert CodecUtil.headerLength(codecNameIdx) == indexStream.getFilePointer();
|
assert CodecUtil.headerLength(codecNameIdx) == indexStream.getFilePointer();
|
||||||
indexReader = new CompressingStoredFieldsIndexReader(indexStream, si);
|
indexReader = new CompressingStoredFieldsIndexReader(indexStream, si);
|
||||||
|
|
||||||
|
long maxPointer = -1;
|
||||||
|
|
||||||
if (version >= VERSION_CHECKSUM) {
|
if (version >= VERSION_CHECKSUM) {
|
||||||
maxPointer = indexStream.readVLong();
|
maxPointer = indexStream.readVLong();
|
||||||
assert maxPointer + CodecUtil.footerLength() == d.fileLength(fieldsStreamFN);
|
|
||||||
CodecUtil.checkFooter(indexStream);
|
CodecUtil.checkFooter(indexStream);
|
||||||
} else {
|
} else {
|
||||||
maxPointer = d.fileLength(fieldsStreamFN);
|
|
||||||
CodecUtil.checkEOF(indexStream);
|
CodecUtil.checkEOF(indexStream);
|
||||||
}
|
}
|
||||||
indexStream.close();
|
indexStream.close();
|
||||||
|
@ -131,6 +131,14 @@ public final class CompressingStoredFieldsReader extends StoredFieldsReader {
|
||||||
|
|
||||||
// Open the data file and read metadata
|
// Open the data file and read metadata
|
||||||
fieldsStream = d.openInput(fieldsStreamFN, context);
|
fieldsStream = d.openInput(fieldsStreamFN, context);
|
||||||
|
if (version >= VERSION_CHECKSUM) {
|
||||||
|
if (maxPointer + CodecUtil.footerLength() != fieldsStream.length()) {
|
||||||
|
throw new CorruptIndexException("Invalid fieldsStream maxPointer (file truncated?): maxPointer=" + maxPointer + ", length=" + fieldsStream.length());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
maxPointer = fieldsStream.length();
|
||||||
|
}
|
||||||
|
this.maxPointer = maxPointer;
|
||||||
final String codecNameDat = formatName + CODEC_SFX_DAT;
|
final String codecNameDat = formatName + CODEC_SFX_DAT;
|
||||||
final int fieldsVersion = CodecUtil.checkHeader(fieldsStream, codecNameDat, VERSION_START, VERSION_CURRENT);
|
final int fieldsVersion = CodecUtil.checkHeader(fieldsStream, codecNameDat, VERSION_START, VERSION_CURRENT);
|
||||||
if (version != fieldsVersion) {
|
if (version != fieldsVersion) {
|
||||||
|
|
Loading…
Reference in New Issue