diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2012-03-28 10:12:20 -0400 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2012-03-28 10:36:51 -0400 |
commit | 6c0d300a54f14fcfbd05dab5756097986b20eca8 (patch) | |
tree | 0aa120fda99a07d54ed50285f75ee1fc016d8657 /org.eclipse.jgit.storage.dht | |
parent | 55bf06b43d8e8ed2f15357e4ecf26eefbff31e29 (diff) | |
download | jgit-6c0d300a54f14fcfbd05dab5756097986b20eca8.tar.gz jgit-6c0d300a54f14fcfbd05dab5756097986b20eca8.zip |
Fix loading packed objects >2G
Parsing the size from a packed object header was incorrectly computing
the total inflated length when the length exceeded the range of a Java
int. The next 7 bits of size information was shifted left as an int
using a shift of 25 bits, placing the higher bits of the size into the
sign position. When this size was extended to a long to be added to
the current size accumulator the size went negative, resulting in
NegativeArraySizeException being thrown.
Fix all places where this particular pattern of code is used to read a
pack size field, or a binary delta header, as they both use the same
variable length encoding scheme.
Change-Id: I04008728ed828f18202652c3d5401cf95a441d0a
Diffstat (limited to 'org.eclipse.jgit.storage.dht')
-rw-r--r-- | org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/PackChunk.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/PackChunk.java b/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/PackChunk.java index 66d3d3386b..57d357e4cf 100644 --- a/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/PackChunk.java +++ b/org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/PackChunk.java @@ -349,7 +349,7 @@ public final class PackChunk { int p = 1; while ((c & 0x80) != 0) { c = dataBuf[posPtr + p++] & 0xff; - sz += (c & 0x7f) << shift; + sz += ((long) (c & 0x7f)) << shift; shift += 7; } @@ -603,7 +603,7 @@ public final class PackChunk { int shift = 4; while ((c & 0x80) != 0) { c = dataBuf[ptr++] & 0xff; - sz += (c & 0x7f) << shift; + sz += ((long) (c & 0x7f)) << shift; shift += 7; } @@ -650,7 +650,7 @@ public final class PackChunk { int shift = 4; while ((c & 0x80) != 0) { c = dataBuf[ptr++] & 0xff; - inflatedSize += (c & 0x7f) << shift; + inflatedSize += ((long) (c & 0x7f)) << shift; shift += 7; } |