diff options
author | Dianne Hackborn <hackbod@google.com> | 2010-12-07 23:00:49 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-12-07 23:00:49 -0800 |
commit | 3fa82a9fe89c55e4217307e06cc185812ad5a8f5 (patch) | |
tree | 3dc6b1812f60f721e81a6920c8b90f69f144528c /core/java/com | |
parent | 3de0f1a05f2ee905bf9d0a1cbe84759335dd9170 (diff) | |
parent | c4b7088f19f8111ea5f34fba41da4a93899708cd (diff) | |
download | frameworks_base-3fa82a9fe89c55e4217307e06cc185812ad5a8f5.zip frameworks_base-3fa82a9fe89c55e4217307e06cc185812ad5a8f5.tar.gz frameworks_base-3fa82a9fe89c55e4217307e06cc185812ad5a8f5.tar.bz2 |
am c4b7088f: am 42a23783: Merge "Add more checks for bad values to protect from corrupt files." into gingerbread
* commit 'c4b7088f19f8111ea5f34fba41da4a93899708cd':
Add more checks for bad values to protect from corrupt files.
Diffstat (limited to 'core/java/com')
-rw-r--r-- | core/java/com/android/internal/os/BatteryStatsImpl.java | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 630830d..145feb5 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -3090,13 +3090,18 @@ public final class BatteryStatsImpl extends BatteryStats { } } - void readExcessivePowerFromParcelLocked(Parcel in) { + boolean readExcessivePowerFromParcelLocked(Parcel in) { final int N = in.readInt(); if (N == 0) { mExcessivePower = null; - return; + return true; } + if (N > 10000) { + Slog.w(TAG, "File corrupt: too many excessive power entries " + N); + return false; + } + mExcessivePower = new ArrayList<ExcessivePower>(); for (int i=0; i<N; i++) { ExcessivePower ew = new ExcessivePower(); @@ -3105,6 +3110,7 @@ public final class BatteryStatsImpl extends BatteryStats { ew.usedTime = in.readLong(); mExcessivePower.add(ew); } + return true; } void writeToParcelLocked(Parcel out) { @@ -4700,7 +4706,7 @@ public final class BatteryStatsImpl extends BatteryStats { } int NW = in.readInt(); - if (NW > 10000) { + if (NW > 100) { Slog.w(TAG, "File corrupt: too many wake locks " + NW); return; } @@ -4718,7 +4724,7 @@ public final class BatteryStatsImpl extends BatteryStats { } int NP = in.readInt(); - if (NP > 10000) { + if (NP > 1000) { Slog.w(TAG, "File corrupt: too many sensors " + NP); return; } @@ -4731,7 +4737,7 @@ public final class BatteryStatsImpl extends BatteryStats { } NP = in.readInt(); - if (NP > 10000) { + if (NP > 1000) { Slog.w(TAG, "File corrupt: too many processes " + NP); return; } @@ -4742,6 +4748,10 @@ public final class BatteryStatsImpl extends BatteryStats { p.mSystemTime = p.mLoadedSystemTime = in.readLong(); p.mStarts = p.mLoadedStarts = in.readInt(); int NSB = in.readInt(); + if (NSB > 100) { + Slog.w(TAG, "File corrupt: too many speed bins " + NSB); + return; + } p.mSpeedBins = new SamplingCounter[NSB]; for (int i=0; i<NSB; i++) { if (in.readInt() != 0) { @@ -4749,7 +4759,9 @@ public final class BatteryStatsImpl extends BatteryStats { p.mSpeedBins[i].readSummaryFromParcelLocked(in); } } - p.readExcessivePowerFromParcelLocked(in); + if (!p.readExcessivePowerFromParcelLocked(in)) { + return; + } } NP = in.readInt(); @@ -4762,6 +4774,10 @@ public final class BatteryStatsImpl extends BatteryStats { Uid.Pkg p = u.getPackageStatsLocked(pkgName); p.mWakeups = p.mLoadedWakeups = in.readInt(); final int NS = in.readInt(); + if (NS > 1000) { + Slog.w(TAG, "File corrupt: too many services " + NS); + return; + } for (int is = 0; is < NS; is++) { String servName = in.readString(); Uid.Pkg.Serv s = u.getServiceStatsLocked(pkgName, servName); |