]> source.dussan.org Git - jgit.git/commitdiff
Fix IOOBE in Repository.resolveSimple() 64/4164/1
authorDariusz Luksza <dariusz@luksza.org>
Tue, 6 Sep 2011 08:12:39 +0000 (10:12 +0200)
committerDariusz Luksza <dariusz@luksza.org>
Tue, 6 Sep 2011 08:12:39 +0000 (10:12 +0200)
IndexOutOfBoundException is thrown from Repository.resolveSimple() when
'-g' string is located less then 4 characters from the end of this
string.

Change-Id: I1128c2cdfec9db3023d4d0f1f40d863e84b75950
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java

index b51a954ca99d38afa68c9bdbede173b2e2609883..3a3e1c558f7c90d8369b58562268013e2e64384c 100644 (file)
@@ -597,7 +597,7 @@ public abstract class Repository {
                        return resolveAbbreviation(revstr);
 
                int dashg = revstr.indexOf("-g");
-               if (4 < revstr.length() && 0 <= dashg
+               if ((dashg + 4) < revstr.length() && 0 <= dashg
                                && isHex(revstr.charAt(dashg + 2))
                                && isHex(revstr.charAt(dashg + 3))
                                && isAllHex(revstr, dashg + 4)) {