diff options
author | Marc Strapetz <marc.strapetz@syntevo.com> | 2014-08-15 14:02:16 +0200 |
---|---|---|
committer | Marc Strapetz <marc.strapetz@syntevo.com> | 2014-08-29 10:08:42 +0200 |
commit | 6be184e15ca1c3d1b50d269dd94973c24773f6ec (patch) | |
tree | 147b7249569af84f155ca51cd3c1a9f7629416c8 /org.eclipse.jgit/src | |
parent | 9ea357f336da08b97617b3bdd9c008fd6382f38f (diff) | |
download | jgit-6be184e15ca1c3d1b50d269dd94973c24773f6ec.tar.gz jgit-6be184e15ca1c3d1b50d269dd94973c24773f6ec.zip |
PackIndexV2 should check for possible corruption
Change-Id: I1803ec6d8141f07dd4085778da6461abe81c30a9
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java | 1 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV2.java | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java index ed94514924..5d9524beda 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java @@ -303,6 +303,7 @@ public class JGitText extends TranslationBundle { /***/ public String improperlyPaddedBase64Input; /***/ public String incorrectHashFor; /***/ public String incorrectOBJECT_ID_LENGTH; + /***/ public String indexFileCorruptedNegativeBucketCount; /***/ public String indexFileIsInUse; /***/ public String indexFileIsTooLargeForJgit; /***/ public String indexSignatureIsInvalid; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV2.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV2.java index 5a5d1f77d9..70cf20fb99 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV2.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV2.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.internal.storage.file; import java.io.IOException; import java.io.InputStream; +import java.text.MessageFormat; import java.util.Arrays; import java.util.Iterator; import java.util.NoSuchElementException; @@ -113,7 +114,10 @@ class PackIndexV2 extends PackIndex { offset32[k] = NO_BYTES; crc32[k] = NO_BYTES; continue; - } + } else if (bucketCnt < 0) + throw new IOException(MessageFormat.format( + JGitText.get().indexFileCorruptedNegativeBucketCount, + Long.valueOf(bucketCnt))); final long nameLen = bucketCnt * Constants.OBJECT_ID_LENGTH; if (nameLen > Integer.MAX_VALUE - 8) // see http://stackoverflow.com/a/8381338 |