]> source.dussan.org Git - jgit.git/commitdiff
Remove unnecessary truncation of in-pack size during copy 12/712/2
authorShawn O. Pearce <spearce@spearce.org>
Sun, 16 May 2010 02:10:47 +0000 (19:10 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 17 May 2010 14:13:55 +0000 (07:13 -0700)
The number of bytes to copy was truncated to an int, but the
pack's copyToStream() method expected to be passed a long here.
Pass through the long so we don't truncate a giant object.

Change-Id: I0786ad60a3a33f84d8746efe51f68d64e127c332
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.eclipse.jgit/src/org/eclipse/jgit/lib/PackFile.java

index 28edf30cd336c700f21907e7739ae3c5f6a926e6..63f51626315fb60d37c8c665266e0eec20df6d81 100644 (file)
@@ -270,7 +270,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
                        throws IOException {
                final long objectOffset = loader.objectOffset;
                final long dataOffset = objectOffset + loader.headerSize;
-               final int cnt = (int) (findEndOffset(objectOffset) - dataOffset);
+               final long sz = findEndOffset(objectOffset) - dataOffset;
                final PackIndex idx = idx();
 
                if (idx.hasCRC32Support()) {
@@ -283,7 +283,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
                                headerCnt -= toRead;
                        }
                        final CheckedOutputStream crcOut = new CheckedOutputStream(out, crc);
-                       copyToStream(dataOffset, buf, cnt, crcOut, curs);
+                       copyToStream(dataOffset, buf, sz, crcOut, curs);
                        final long computed = crc.getValue();
 
                        final ObjectId id = findObjectForOffset(objectOffset);
@@ -301,7 +301,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
                                coe.initCause(dfe);
                                throw coe;
                        }
-                       copyToStream(dataOffset, buf, cnt, out, curs);
+                       copyToStream(dataOffset, buf, sz, out, curs);
                }
        }