Skip to content

Commit b0a579f

Browse files
committed
Sanity check network stats coming from disk.
Throw early when structure is unstable, which allows the normal recoverFromWtf() path to recover automatically. Bug: 7440485 Change-Id: Ic150d17daac4de7c9ff3489025403a9b485b4620
1 parent 44251a7 commit b0a579f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

core/java/android/net/NetworkStatsHistory.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ public NetworkStatsHistory(DataInputStream in) throws IOException {
177177
throw new ProtocolException("unexpected version: " + version);
178178
}
179179
}
180+
181+
if (bucketStart.length != bucketCount || rxBytes.length != bucketCount
182+
|| rxPackets.length != bucketCount || txBytes.length != bucketCount
183+
|| txPackets.length != bucketCount || operations.length != bucketCount) {
184+
throw new ProtocolException("Mismatched history lengths");
185+
}
180186
}
181187

182188
public void writeToStream(DataOutputStream out) throws IOException {

0 commit comments

Comments
 (0)