From 06af46922ee5ad46f9269713f7a11ddbb6e748b6 Mon Sep 17 00:00:00 2001 From: Gavin Li Date: Thu, 15 Oct 2015 15:55:48 -0700 Subject: [PATCH] StrictMode: fix deserialization of ViolationInfo on large stacks When a large stack trace is encountered, one too many ViolationInfo objects would be drained, which may cause a system_server crash when readStringArray() is called on incorrect data. Change-Id: Icb30d0402638ea5b6d63004b598d2f0bb276d685 --- core/java/android/os/StrictMode.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java index 87ce12cbe37ce..58d4d09bcfc78 100644 --- a/core/java/android/os/StrictMode.java +++ b/core/java/android/os/StrictMode.java @@ -1931,9 +1931,9 @@ public final class StrictMode { // so we'll report it and bail on all of the current strict mode violations // we currently are maintaining for this thread. // First, drain the remaining violations from the parcel. - while (i < numViolations) { + i++; // Skip the current entry. + for (; i < numViolations; i++) { info = new ViolationInfo(p, !currentlyGathering); - i++; } // Next clear out all gathered violations. clearGatheredViolations();