From 6f7130140410d9c8269b846e782f27df17783c35 Mon Sep 17 00:00:00 2001 From: Christian Halstrick Date: Mon, 4 May 2015 11:00:57 +0200 Subject: [PATCH] Fix possible AIOOB in DirCacheTree.contains() When DirCacheTree.contains() is called and 'aOff' is greater than 'aLen' an ArrayIndexOutOfBoundsException was thrown. This fix makes DirCacheTree.contains() more robust and allows parsing such index files without throwing AIOOB. I couldn't create a test case leading to this situation but I have seen such situations while inspecting Bug: 465393. It seems that such situations are created on Windows when there are invalid pathes in the index. There may be a not yet known bug leading to such situations in combination with invalid pathes. Bug: 465393 Change-Id: I6535d924a22cba9a05df0ccd7e6dc2c9ddc42375 --- .../src/org/eclipse/jgit/dircache/DirCacheTree.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheTree.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheTree.java index 30932e827..83aa8fa4d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheTree.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheTree.java @@ -399,7 +399,7 @@ public class DirCacheTree { for (int eOff = 0; eOff < eLen && aOff < aLen; eOff++, aOff++) if (e[eOff] != a[aOff]) return false; - if (aOff == aLen) + if (aOff >= aLen) return false; return a[aOff] == '/'; }