Browse Source

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 <spearce@spearce.org>
stable-0.9
Shawn O. Pearce 14 years ago
parent
commit
b518189b5c
  1. 6
      org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java

6
org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java

@ -961,7 +961,7 @@ public class IndexPack {
int p = fill(src, 24); int p = fill(src, 24);
inf.setInput(buf, p, bAvail); inf.setInput(buf, p, bAvail);
do { for (;;) {
int r = inf.inflate(dst, off, dst.length - off); int r = inf.inflate(dst, off, dst.length - off);
if (r == 0) { if (r == 0) {
if (inf.finished()) if (inf.finished())
@ -982,9 +982,9 @@ public class IndexPack {
cnt += r; cnt += r;
if (keep) if (keep)
off += r; off += r;
} while (cnt < inflatedSize); }
if (!inf.finished() || cnt != inflatedSize) { if (cnt != inflatedSize) {
throw new CorruptObjectException(MessageFormat.format(JGitText throw new CorruptObjectException(MessageFormat.format(JGitText
.get().packfileCorruptionDetected, .get().packfileCorruptionDetected,
JGitText.get().wrongDecompressedLength)); JGitText.get().wrongDecompressedLength));

Loading…
Cancel
Save