Range check in MediaScanner::processDirectory

Make sure we don't have an empty string before checking if it's a
directory since this string is tainted.

Change-Id: I5eb310ced58c3c64a7af2d11b80326efe5adbcab
This commit is contained in:
Kenny Root
2010-02-18 09:25:49 -08:00
parent c948cc8c8a
commit 7fe4fe68fa

View File

@@ -58,7 +58,7 @@ status_t MediaScanner::processDirectory(
int pathRemaining = PATH_MAX - pathLength;
strcpy(pathBuffer, path);
if (pathBuffer[pathLength - 1] != '/') {
if (pathLength > 0 && pathBuffer[pathLength - 1]) {
pathBuffer[pathLength] = '/';
pathBuffer[pathLength + 1] = 0;
--pathRemaining;