lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1580024 - in /lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs: compressing/ lucene42/ lucene45/
Date Fri, 21 Mar 2014 19:27:13 GMT
Author: rmuir
Date: Fri Mar 21 19:27:13 2014
New Revision: 1580024

URL: http://svn.apache.org/r1580024
Log:
add missing safety checks for metadata files

Modified:
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42DocValuesProducer.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java?rev=1580024&r1=1580023&r2=1580024&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java
Fri Mar 21 19:27:13 2014
@@ -122,6 +122,9 @@ public final class CompressingStoredFiel
       version = CodecUtil.checkHeader(indexStream, codecNameIdx, VERSION_START, VERSION_CURRENT);
       assert CodecUtil.headerLength(codecNameIdx) == indexStream.getFilePointer();
       indexReader = new CompressingStoredFieldsIndexReader(indexStream, si);
+      if (indexStream.getFilePointer() != indexStream.length()) {
+        throw new CorruptIndexException("did not read all bytes from file \"" + indexStreamFN
+ "\": read " + indexStream.getFilePointer() + " vs size " + indexStream.length() + " (resource:
" + indexStream + ")");
+      }
       indexStream.close();
       indexStream = null;
 

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java?rev=1580024&r1=1580023&r2=1580024&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java
Fri Mar 21 19:27:13 2014
@@ -105,9 +105,12 @@ public final class CompressingTermVector
       final String indexStreamFN = IndexFileNames.segmentFileName(segment, segmentSuffix,
VECTORS_INDEX_EXTENSION);
       indexStream = d.openInput(indexStreamFN, context);
       final String codecNameIdx = formatName + CODEC_SFX_IDX;
-      CodecUtil.checkHeader(indexStream, codecNameIdx, VERSION_START, VERSION_CURRENT);
+      int version = CodecUtil.checkHeader(indexStream, codecNameIdx, VERSION_START, VERSION_CURRENT);
       assert CodecUtil.headerLength(codecNameIdx) == indexStream.getFilePointer();
       indexReader = new CompressingStoredFieldsIndexReader(indexStream, si);
+      if (indexStream.getFilePointer() != indexStream.length()) {
+        throw new CorruptIndexException("did not read all bytes from file \"" + indexStreamFN
+ "\": read " + indexStream.getFilePointer() + " vs size " + indexStream.length() + " (resource:
" + indexStream + ")");
+      }
       indexStream.close();
       indexStream = null;
 
@@ -115,7 +118,10 @@ public final class CompressingTermVector
       final String vectorsStreamFN = IndexFileNames.segmentFileName(segment, segmentSuffix,
VECTORS_EXTENSION);
       vectorsStream = d.openInput(vectorsStreamFN, context);
       final String codecNameDat = formatName + CODEC_SFX_DAT;
-      CodecUtil.checkHeader(vectorsStream, codecNameDat, VERSION_START, VERSION_CURRENT);
+      int version2 = CodecUtil.checkHeader(vectorsStream, codecNameDat, VERSION_START, VERSION_CURRENT);
+      if (version != version2) {
+        throw new CorruptIndexException("Version mismatch between stored fields index and
data: " + version + " != " + version2);
+      }
       assert CodecUtil.headerLength(codecNameDat) == vectorsStream.getFilePointer();
 
       packedIntsVersion = vectorsStream.readVInt();

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42DocValuesProducer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42DocValuesProducer.java?rev=1580024&r1=1580023&r2=1580024&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42DocValuesProducer.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42DocValuesProducer.java
Fri Mar 21 19:27:13 2014
@@ -108,6 +108,10 @@ class Lucene42DocValuesProducer extends 
       fsts = new HashMap<>();
       readFields(in, state.fieldInfos);
 
+      if (in.getFilePointer() != in.length()) {
+        throw new CorruptIndexException("did not read all bytes from file \"" + metaName
+ "\": read " + in.getFilePointer() + " vs size " + in.length() + " (resource: " + in + ")");
+      }
+      
       success = true;
     } finally {
       if (success) {

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java?rev=1580024&r1=1580023&r2=1580024&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java
Fri Mar 21 19:27:13 2014
@@ -94,6 +94,10 @@ public class Lucene45DocValuesProducer e
       sortedSets = new HashMap<>();
       readFields(in, state.fieldInfos);
 
+      if (in.getFilePointer() != in.length()) {
+        throw new CorruptIndexException("did not read all bytes from file \"" + metaName
+ "\": read " + in.getFilePointer() + " vs size " + in.length() + " (resource: " + in + ")");
+      }
+
       success = true;
     } finally {
       if (success) {



Mime
View raw message