From b518189b5c580e21c5f6d8a3b59e7f1538f0110e Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 20 Jul 2010 07:40:48 -0700 Subject: [PATCH] IndexPack: Fix spurious pack file corruption errors We didn't correctly handle the zlib trailer for an object. If the trailer bytes were outside of the current buffer window but we had fully inflated the object itself, we broke out of the loop (as we had our target size) but inflate wasn't finished (as it did not yet get the trailer) so we failed the test and threw a corruption exception. Use an infinite loop and only break out when the inflater is done. Change-Id: I7c9bbbeb577a990d9bc56a50ebd485935460f6c8 Signed-off-by: Shawn O. Pearce --- .../src/org/eclipse/jgit/transport/IndexPack.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java index 789d8cdd7..491227d09 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java @@ -961,7 +961,7 @@ public class IndexPack { int p = fill(src, 24); inf.setInput(buf, p, bAvail); - do { + for (;;) { int r = inf.inflate(dst, off, dst.length - off); if (r == 0) { if (inf.finished()) @@ -982,9 +982,9 @@ public class IndexPack { cnt += r; if (keep) off += r; - } while (cnt < inflatedSize); + } - if (!inf.finished() || cnt != inflatedSize) { + if (cnt != inflatedSize) { throw new CorruptObjectException(MessageFormat.format(JGitText .get().packfileCorruptionDetected, JGitText.get().wrongDecompressedLength));