Merge "Corrected buffer overflow when parsing /proc/wakelocks"

This commit is contained in:
Romain Guy
2010-07-29 14:00:48 -07:00
committed by Android Code Review

View File

@ -844,7 +844,7 @@ public final class BatteryStatsImpl extends BatteryStats {
private final Map<String, KernelWakelockStats> readKernelWakelockStats() {
byte[] buffer = new byte[4096];
byte[] buffer = new byte[8192];
int len;
try {
@ -891,9 +891,11 @@ public final class BatteryStatsImpl extends BatteryStats {
for (endIndex=startIndex;
endIndex < len && wlBuffer[endIndex] != '\n' && wlBuffer[endIndex] != '\0';
endIndex++);
// Don't go over the end of the buffer
if (endIndex < len) {
endIndex++; // endIndex is an exclusive upper bound.
endIndex++; // endIndex is an exclusive upper bound.
// Don't go over the end of the buffer, Process.parseProcLine might
// write to wlBuffer[endIndex]
if (endIndex >= (len - 1) ) {
return m;
}
String[] nameStringArray = mProcWakelocksName;