aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java8
2 files changed, 7 insertions, 3 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java
index b2497b879a..3cce3d71f3 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java
@@ -270,7 +270,7 @@ public class PackParserTest extends RepositoryTestCase {
fail("PackParser should have failed");
} catch (TooLargeObjectInPackException e) {
assertTrue(e.getMessage().contains("13")); // max obj size
- assertFalse(e.getMessage().contains("14")); // no delta size
+ assertTrue(e.getMessage().contains("14")); // delta size
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java
index 833d2114cf..d2ec39c0c5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java
@@ -701,7 +701,7 @@ public abstract class PackParser {
private final void checkIfTooLarge(int typeCode, long size)
throws IOException {
- if (0 < maxObjectSizeLimit && maxObjectSizeLimit < size)
+ if (0 < maxObjectSizeLimit && maxObjectSizeLimit < size) {
switch (typeCode) {
case Constants.OBJ_COMMIT:
case Constants.OBJ_TREE:
@@ -711,13 +711,17 @@ public abstract class PackParser {
case Constants.OBJ_OFS_DELTA:
case Constants.OBJ_REF_DELTA:
- throw new TooLargeObjectInPackException(maxObjectSizeLimit);
+ throw new TooLargeObjectInPackException(size, maxObjectSizeLimit);
default:
throw new IOException(MessageFormat.format(
JGitText.get().unknownObjectType,
Integer.valueOf(typeCode)));
}
+ }
+ if (size > Integer.MAX_VALUE - 8) {
+ throw new TooLargeObjectInPackException(size, Integer.MAX_VALUE - 8);
+ }
}
/**