]> source.dussan.org Git - jgit.git/commitdiff
PackIndexV2: fix possibly wrong check 52/31752/1
authorMarc Strapetz <marc.strapetz@syntevo.com>
Fri, 15 Aug 2014 12:00:40 +0000 (14:00 +0200)
committerMarc Strapetz <marc.strapetz@syntevo.com>
Fri, 15 Aug 2014 12:01:09 +0000 (14:01 +0200)
According to http://stackoverflow.com/a/8381338, the maximum array
size is not Integer.MAX_VALUE, but Integer.MAX_VALUE - 8

Change-Id: I6ddc7470368acd20abf0885c53c89a982bb0f176
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV2.java

index 9d2caa2e880d449c85d95e999296df8c9eec5f90..5a5d1f77d99ab6f26b32812bfaf7cb038a3fdc97 100644 (file)
@@ -116,7 +116,7 @@ class PackIndexV2 extends PackIndex {
                        }
 
                        final long nameLen = bucketCnt * Constants.OBJECT_ID_LENGTH;
-                       if (nameLen > Integer.MAX_VALUE)
+                       if (nameLen > Integer.MAX_VALUE - 8) // see http://stackoverflow.com/a/8381338
                                throw new IOException(JGitText.get().indexFileIsTooLargeForJgit);
 
                        final int intNameLen = (int) nameLen;