@@ -3079,13 +3079,18 @@ void writeExcessivePowerToParcelLocked(Parcel out) {
30793079 }
30803080 }
30813081
3082- void readExcessivePowerFromParcelLocked (Parcel in ) {
3082+ boolean readExcessivePowerFromParcelLocked (Parcel in ) {
30833083 final int N = in .readInt ();
30843084 if (N == 0 ) {
30853085 mExcessivePower = null ;
3086- return ;
3086+ return true ;
30873087 }
30883088
3089+ if (N > 10000 ) {
3090+ Slog .w (TAG , "File corrupt: too many excessive power entries " + N );
3091+ return false ;
3092+ }
3093+
30893094 mExcessivePower = new ArrayList <ExcessivePower >();
30903095 for (int i =0 ; i <N ; i ++) {
30913096 ExcessivePower ew = new ExcessivePower ();
@@ -3094,6 +3099,7 @@ void readExcessivePowerFromParcelLocked(Parcel in) {
30943099 ew .usedTime = in .readLong ();
30953100 mExcessivePower .add (ew );
30963101 }
3102+ return true ;
30973103 }
30983104
30993105 void writeToParcelLocked (Parcel out ) {
@@ -4689,7 +4695,7 @@ private void readSummaryFromParcel(Parcel in) {
46894695 }
46904696
46914697 int NW = in .readInt ();
4692- if (NW > 10000 ) {
4698+ if (NW > 100 ) {
46934699 Slog .w (TAG , "File corrupt: too many wake locks " + NW );
46944700 return ;
46954701 }
@@ -4707,7 +4713,7 @@ private void readSummaryFromParcel(Parcel in) {
47074713 }
47084714
47094715 int NP = in .readInt ();
4710- if (NP > 10000 ) {
4716+ if (NP > 1000 ) {
47114717 Slog .w (TAG , "File corrupt: too many sensors " + NP );
47124718 return ;
47134719 }
@@ -4720,7 +4726,7 @@ private void readSummaryFromParcel(Parcel in) {
47204726 }
47214727
47224728 NP = in .readInt ();
4723- if (NP > 10000 ) {
4729+ if (NP > 1000 ) {
47244730 Slog .w (TAG , "File corrupt: too many processes " + NP );
47254731 return ;
47264732 }
@@ -4731,14 +4737,20 @@ private void readSummaryFromParcel(Parcel in) {
47314737 p .mSystemTime = p .mLoadedSystemTime = in .readLong ();
47324738 p .mStarts = p .mLoadedStarts = in .readInt ();
47334739 int NSB = in .readInt ();
4740+ if (NSB > 100 ) {
4741+ Slog .w (TAG , "File corrupt: too many speed bins " + NSB );
4742+ return ;
4743+ }
47344744 p .mSpeedBins = new SamplingCounter [NSB ];
47354745 for (int i =0 ; i <NSB ; i ++) {
47364746 if (in .readInt () != 0 ) {
47374747 p .mSpeedBins [i ] = new SamplingCounter (mUnpluggables );
47384748 p .mSpeedBins [i ].readSummaryFromParcelLocked (in );
47394749 }
47404750 }
4741- p .readExcessivePowerFromParcelLocked (in );
4751+ if (!p .readExcessivePowerFromParcelLocked (in )) {
4752+ return ;
4753+ }
47424754 }
47434755
47444756 NP = in .readInt ();
@@ -4751,6 +4763,10 @@ private void readSummaryFromParcel(Parcel in) {
47514763 Uid .Pkg p = u .getPackageStatsLocked (pkgName );
47524764 p .mWakeups = p .mLoadedWakeups = in .readInt ();
47534765 final int NS = in .readInt ();
4766+ if (NS > 1000 ) {
4767+ Slog .w (TAG , "File corrupt: too many services " + NS );
4768+ return ;
4769+ }
47544770 for (int is = 0 ; is < NS ; is ++) {
47554771 String servName = in .readString ();
47564772 Uid .Pkg .Serv s = u .getServiceStatsLocked (pkgName , servName );
0 commit comments