Author: thomasm
Date: Fri Jan 29 07:57:53 2016
New Revision: 1727493
URL: http://svn.apache.org/viewvc?rev=1727493&view=rev
Log:
OAK-3911 Integer overflow causing incorrect file handling in OakDirectory for
file size more than 2 GB (comments)
Modified:
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakDirectory.java
Modified:
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakDirectory.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakDirectory.java?rev=1727493&r1=1727492&r2=1727493&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakDirectory.java
(original)
+++
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakDirectory.java
Fri Jan 29 07:57:53 2016
@@ -418,8 +418,9 @@ class OakDirectory extends Directory {
offset += l;
len -= l;
position += l;
-
+ // next block
i++;
+ // for the next block, we read from the beginning
o = 0;
}
}
@@ -433,8 +434,15 @@ class OakDirectory extends Directory {
if (index != i) {
if (o > 0 || (l < blobSize && position + l < length)) {
+ // loadBlob first flushes the previous block,
+ // and it sets the index
loadBlob(i);
} else {
+ // we don't need to load the block,
+ // as we anyway overwrite it fully, if:
+ // o == 0 (start writing at a block boundary)
+ // and either: l is the blockSize, or
+ // we write at least to the end of the file
flushBlob();
index = i;
}