From 3a8abe7eec556e5626422ec583a0bb4d9f185329 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 2 Nov 2012 14:48:20 -0700 Subject: [PATCH] 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 --- core/java/android/net/NetworkStatsHistory.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/java/android/net/NetworkStatsHistory.java b/core/java/android/net/NetworkStatsHistory.java index a37c26f90d..382b25e377 100644 --- a/core/java/android/net/NetworkStatsHistory.java +++ b/core/java/android/net/NetworkStatsHistory.java @@ -177,6 +177,12 @@ public class NetworkStatsHistory implements Parcelable { throw new ProtocolException("unexpected version: " + version); } } + + if (bucketStart.length != bucketCount || rxBytes.length != bucketCount + || rxPackets.length != bucketCount || txBytes.length != bucketCount + || txPackets.length != bucketCount || operations.length != bucketCount) { + throw new ProtocolException("Mismatched history lengths"); + } } public void writeToStream(DataOutputStream out) throws IOException {