You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2017/05/16 21:11:38 UTC

[1/2] lucene-solr:branch_6_6: LUCENE-7831: CodecUtil should not seek to negative offsets.

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6_6 fb8655073 -> 4d055f00b
  refs/heads/master 0fb89f17e -> 5ba761bcf


LUCENE-7831: CodecUtil should not seek to negative offsets.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/4d055f00
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/4d055f00
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/4d055f00

Branch: refs/heads/branch_6_6
Commit: 4d055f00bba9a745737e4b6c3f9dff06dd35aa2e
Parents: fb86550
Author: Adrien Grand <jp...@gmail.com>
Authored: Tue May 16 18:31:57 2017 +0200
Committer: Adrien Grand <jp...@gmail.com>
Committed: Tue May 16 23:09:46 2017 +0200

----------------------------------------------------------------------
 lucene/CHANGES.txt                                     |  2 ++
 .../src/java/org/apache/lucene/codecs/CodecUtil.java   |  6 ++++++
 .../test/org/apache/lucene/codecs/TestCodecUtil.java   | 13 +++++++++++++
 3 files changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4d055f00/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index a1d26dd..bc718a0 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -45,6 +45,8 @@ Bug Fixes
 * LUCENE-7817: Pass cached query to onQueryCache instead of null.
   (Christoph Kaser via Adrien Grand)
 
+* LUCENE-7831: CodecUtil should not seek to negative offsets. (Adrien Grand)
+
 Improvements
 
 * LUCENE-7782: OfflineSorter now passes the total number of items it

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4d055f00/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java b/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java
index a625b47..c49946b 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java
@@ -331,6 +331,9 @@ public final class CodecUtil {
   /** Retrieves the full footer from the provided {@link IndexInput}.  This throws
    *  {@link CorruptIndexException} if this file does not have a valid footer. */
   public static byte[] readFooter(IndexInput in) throws IOException {
+    if (in.length() < footerLength()) {
+      throw new CorruptIndexException("misplaced codec footer (file truncated?): length=" + in.length() + " but footerLength==" + footerLength(), in);
+    }
     in.seek(in.length() - footerLength());
     validateFooter(in);
     in.seek(in.length() - footerLength());
@@ -516,6 +519,9 @@ public final class CodecUtil {
     clone.seek(0);
     ChecksumIndexInput in = new BufferedChecksumIndexInput(clone);
     assert in.getFilePointer() == 0;
+    if (in.length() < footerLength()) {
+      throw new CorruptIndexException("misplaced codec footer (file truncated?): length=" + in.length() + " but footerLength==" + footerLength(), input);
+    }
     in.seek(in.length() - footerLength());
     return checkFooter(in);
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4d055f00/lucene/core/src/test/org/apache/lucene/codecs/TestCodecUtil.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/codecs/TestCodecUtil.java b/lucene/core/src/test/org/apache/lucene/codecs/TestCodecUtil.java
index d403f81..0ff7f7c 100644
--- a/lucene/core/src/test/org/apache/lucene/codecs/TestCodecUtil.java
+++ b/lucene/core/src/test/org/apache/lucene/codecs/TestCodecUtil.java
@@ -303,4 +303,17 @@ public class TestCodecUtil extends LuceneTestCase {
     fakeChecksum.set((1L << 32) - 1); // ok
     CodecUtil.writeCRC(fakeOutput);
   }
+
+  public void testTruncatedFileThrowsCorruptIndexException() throws IOException {
+    RAMFile file = new RAMFile();
+    IndexOutput output = new RAMOutputStream(file, false);
+    output.close();
+    IndexInput input = new RAMInputStream("file", file);
+    CorruptIndexException e = expectThrows(CorruptIndexException.class,
+        () -> CodecUtil.checksumEntireFile(input));
+    assertEquals("misplaced codec footer (file truncated?): length=0 but footerLength==16 (resource=RAMInputStream(name=file))", e.getMessage());
+    e = expectThrows(CorruptIndexException.class,
+        () -> CodecUtil.retrieveChecksum(input));
+    assertEquals("misplaced codec footer (file truncated?): length=0 but footerLength==16 (resource=RAMInputStream(name=file))", e.getMessage());
+  }
 }


[2/2] lucene-solr:master: LUCENE-7831: Move CHANGES entry to 6.6.

Posted by jp...@apache.org.
LUCENE-7831: Move CHANGES entry to 6.6.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/5ba761bc
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/5ba761bc
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/5ba761bc

Branch: refs/heads/master
Commit: 5ba761bcf693f3e553489642e2d9f5af09db44cc
Parents: 0fb89f1
Author: Adrien Grand <jp...@gmail.com>
Authored: Tue May 16 23:10:32 2017 +0200
Committer: Adrien Grand <jp...@gmail.com>
Committed: Tue May 16 23:11:18 2017 +0200

----------------------------------------------------------------------
 lucene/CHANGES.txt | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5ba761bc/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index ce6ba67..df8d20d 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -94,10 +94,6 @@ Other
 
 ======================= Lucene 6.7.0 =======================
 
-Bug Fixes
-
-* LUCENE-7831: CodecUtil should not seek to negative offsets. (Adrien Grand)
-
 ======================= Lucene 6.6.0 =======================
 
 New Features
@@ -140,6 +136,8 @@ Bug Fixes
 * LUCENE-7817: Pass cached query to onQueryCache instead of null.
   (Christoph Kaser via Adrien Grand)
 
+* LUCENE-7831: CodecUtil should not seek to negative offsets. (Adrien Grand)
+
 Improvements
 
 * LUCENE-7782: OfflineSorter now passes the total number of items it