Skip to content

Commit

Permalink
Fix potential buffer overrun.
Browse files Browse the repository at this point in the history
BUG=27840771
CYNGNOS-3020

Change-Id: I240f188b2e8f4b45d90138cfb3b14869cf506452
(cherry picked from commit 38025bc)
  • Loading branch information
aartbik authored and Jessica Wagantall committed Jul 8, 2016
1 parent 0f6f6f4 commit f01dac7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libdex/OptInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,18 @@ char* dexOptGenerateCacheFileName(const char* fileName, const char* subFileName)
ALOGE("Can't get CWD while opening jar file");
return NULL;
}
strncat(absoluteFile, "/", kBufLen);
strncat(absoluteFile, "/", kBufLen - strlen(absoluteFile));
}
strncat(absoluteFile, fileName, kBufLen);
strncat(absoluteFile, fileName, kBufLen - strlen(absoluteFile));

/*
* Append the name of the Jar file entry, if any. This is not currently
* required, but will be if we start putting more than one DEX file
* in a Jar.
*/
if (subFileName != NULL) {
strncat(absoluteFile, "/", kBufLen);
strncat(absoluteFile, subFileName, kBufLen);
strncat(absoluteFile, "/", kBufLen - strlen(absoluteFile));
strncat(absoluteFile, subFileName, kBufLen - strlen(absoluteFile));
}

/* Turn the path into a flat filename by replacing
Expand Down Expand Up @@ -138,7 +138,7 @@ char* dexOptGenerateCacheFileName(const char* fileName, const char* subFileName)

/* Tack on the file name for the actual cache file path.
*/
strncat(nameBuf, absoluteFile, kBufLen);
strncat(nameBuf, absoluteFile, kBufLen - strlen(nameBuf));

ALOGV("Cache file for '%s' '%s' is '%s'", fileName, subFileName, nameBuf);
return strdup(nameBuf);
Expand Down

0 comments on commit f01dac7

Please sign in to comment.