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
This commit is contained in:
Christian Halstrick 2015-05-04 11:00:57 +02:00
parent 4a984e2033
commit 6f71301404
1 changed files with 1 additions and 1 deletions

View File

@ -399,7 +399,7 @@ final boolean contains(final byte[] a, int aOff, final int aLen) {
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] == '/';
}