Skip to content
Snippets Groups Projects
Commit d011a377 authored by Chris Aniszczyk's avatar Chris Aniszczyk Committed by Code Review
Browse files

Merge "Fix handling of corruption for truncated objects"

parents 28e42cb4 c10e1341
Branches
Tags
No related merge requests found
...@@ -114,8 +114,13 @@ private UnpackedObjectLoader(final byte[] compressed, final AnyObjectId id) ...@@ -114,8 +114,13 @@ private UnpackedObjectLoader(final byte[] compressed, final AnyObjectId id)
int avail = 0; int avail = 0;
while (!inflater.finished() && avail < hdr.length) while (!inflater.finished() && avail < hdr.length)
try { try {
avail += inflater.inflate(hdr, avail, hdr.length int uncompressed = inflater.inflate(hdr, avail,
- avail); hdr.length - avail);
if (uncompressed == 0) {
throw new CorruptObjectException(id,
"bad stream, corrupt header");
}
avail += uncompressed;
} catch (DataFormatException dfe) { } catch (DataFormatException dfe) {
final CorruptObjectException coe; final CorruptObjectException coe;
coe = new CorruptObjectException(id, "bad stream"); coe = new CorruptObjectException(id, "bad stream");
...@@ -172,8 +177,14 @@ private UnpackedObjectLoader(final byte[] compressed, final AnyObjectId id) ...@@ -172,8 +177,14 @@ private UnpackedObjectLoader(final byte[] compressed, final AnyObjectId id)
private void decompress(final AnyObjectId id, final Inflater inf, int p) private void decompress(final AnyObjectId id, final Inflater inf, int p)
throws CorruptObjectException { throws CorruptObjectException {
try { try {
while (!inf.finished()) while (!inf.finished()) {
p += inf.inflate(bytes, p, objectSize - p); int uncompressed = inf.inflate(bytes, p, objectSize - p);
p += uncompressed;
if (uncompressed == 0 && !inf.finished()) {
throw new CorruptObjectException(id,
"bad stream, corrupt header");
}
}
} catch (DataFormatException dfe) { } catch (DataFormatException dfe) {
final CorruptObjectException coe; final CorruptObjectException coe;
coe = new CorruptObjectException(id, "bad stream"); coe = new CorruptObjectException(id, "bad stream");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment