@@ -3077,13 +3077,18 @@ void writeExcessivePowerToParcelLocked(Parcel out) {
30773077 }
30783078 }
30793079
3080- void readExcessivePowerFromParcelLocked (Parcel in ) {
3080+ boolean readExcessivePowerFromParcelLocked (Parcel in ) {
30813081 final int N = in .readInt ();
30823082 if (N == 0 ) {
30833083 mExcessivePower = null ;
3084- return ;
3084+ return true ;
30853085 }
30863086
3087+ if (N > 10000 ) {
3088+ Slog .w (TAG , "File corrupt: too many excessive power entries " + N );
3089+ return false ;
3090+ }
3091+
30873092 mExcessivePower = new ArrayList <ExcessivePower >();
30883093 for (int i =0 ; i <N ; i ++) {
30893094 ExcessivePower ew = new ExcessivePower ();
@@ -3092,6 +3097,7 @@ void readExcessivePowerFromParcelLocked(Parcel in) {
30923097 ew .usedTime = in .readLong ();
30933098 mExcessivePower .add (ew );
30943099 }
3100+ return true ;
30953101 }
30963102
30973103 void writeToParcelLocked (Parcel out ) {
@@ -4687,7 +4693,7 @@ private void readSummaryFromParcel(Parcel in) {
46874693 }
46884694
46894695 int NW = in .readInt ();
4690- if (NW > 10000 ) {
4696+ if (NW > 100 ) {
46914697 Slog .w (TAG , "File corrupt: too many wake locks " + NW );
46924698 return ;
46934699 }
@@ -4705,7 +4711,7 @@ private void readSummaryFromParcel(Parcel in) {
47054711 }
47064712
47074713 int NP = in .readInt ();
4708- if (NP > 10000 ) {
4714+ if (NP > 1000 ) {
47094715 Slog .w (TAG , "File corrupt: too many sensors " + NP );
47104716 return ;
47114717 }
@@ -4718,7 +4724,7 @@ private void readSummaryFromParcel(Parcel in) {
47184724 }
47194725
47204726 NP = in .readInt ();
4721- if (NP > 10000 ) {
4727+ if (NP > 1000 ) {
47224728 Slog .w (TAG , "File corrupt: too many processes " + NP );
47234729 return ;
47244730 }
@@ -4729,14 +4735,20 @@ private void readSummaryFromParcel(Parcel in) {
47294735 p .mSystemTime = p .mLoadedSystemTime = in .readLong ();
47304736 p .mStarts = p .mLoadedStarts = in .readInt ();
47314737 int NSB = in .readInt ();
4738+ if (NSB > 100 ) {
4739+ Slog .w (TAG , "File corrupt: too many speed bins " + NSB );
4740+ return ;
4741+ }
47324742 p .mSpeedBins = new SamplingCounter [NSB ];
47334743 for (int i =0 ; i <NSB ; i ++) {
47344744 if (in .readInt () != 0 ) {
47354745 p .mSpeedBins [i ] = new SamplingCounter (mUnpluggables );
47364746 p .mSpeedBins [i ].readSummaryFromParcelLocked (in );
47374747 }
47384748 }
4739- p .readExcessivePowerFromParcelLocked (in );
4749+ if (!p .readExcessivePowerFromParcelLocked (in )) {
4750+ return ;
4751+ }
47404752 }
47414753
47424754 NP = in .readInt ();
@@ -4749,6 +4761,10 @@ private void readSummaryFromParcel(Parcel in) {
47494761 Uid .Pkg p = u .getPackageStatsLocked (pkgName );
47504762 p .mWakeups = p .mLoadedWakeups = in .readInt ();
47514763 final int NS = in .readInt ();
4764+ if (NS > 1000 ) {
4765+ Slog .w (TAG , "File corrupt: too many services " + NS );
4766+ return ;
4767+ }
47524768 for (int is = 0 ; is < NS ; is ++) {
47534769 String servName = in .readString ();
47544770 Uid .Pkg .Serv s = u .getServiceStatsLocked (pkgName , servName );
0 commit comments