diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlock.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlock.java index 79265363e..4a33fb87e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlock.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlock.java @@ -88,9 +88,16 @@ final class DfsBlock { return n; } - int setInput(long pos, Inflater inf) { + int setInput(long pos, Inflater inf) throws DataFormatException { int ptr = (int) (pos - start); int cnt = block.length - ptr; + if (cnt <= 0) { + throw new DataFormatException(cnt + " bytes to inflate:" //$NON-NLS-1$ + + " at pos=" + pos //$NON-NLS-1$ + + "; block.start=" + start //$NON-NLS-1$ + + "; ptr=" + ptr //$NON-NLS-1$ + + "; block.length=" + block.length); //$NON-NLS-1$ + } inf.setInput(block, ptr, cnt); return cnt; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java index 3e8deac0f..c57c41741 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java @@ -484,7 +484,8 @@ public class DfsInserter extends ObjectInserter { } } - private int setInput(long pos, Inflater inf) throws IOException { + private int setInput(long pos, Inflater inf) + throws IOException, DataFormatException { if (pos < currPos) return getOrLoadBlock(pos).setInput(pos, inf); if (pos < currPos + currPtr) {