summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hans Boehm <hboehm@google.com> 2024-01-02 16:53:13 -0800
committer Hans Boehm <hboehm@google.com> 2024-01-05 15:32:59 -0800
commit7ba059e2cf0a2c20f9a849719cdc32b12c933a44 (patch)
treea0ba46688a06be0014593a90edc45101b17e4cca
parent9534d497232d5253a716c6224065a96b7def1318 (diff)
Check hidden API exemptions
Refuse to deal with newlines and null characters in HiddenApiSettings.update(). Also disallow nulls in process start arguments. Bug: 316153291 Test: Treehugger for now Change-Id: I83cd60e46407a4a082f9f3c80e937dbd522dbac4
-rw-r--r--core/java/android/os/ZygoteProcess.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/java/android/os/ZygoteProcess.java b/core/java/android/os/ZygoteProcess.java
index c14810bbcd64..f3496e7f2592 100644
--- a/core/java/android/os/ZygoteProcess.java
+++ b/core/java/android/os/ZygoteProcess.java
@@ -425,6 +425,8 @@ public class ZygoteProcess {
throw new ZygoteStartFailedEx("Embedded newlines not allowed");
} else if (arg.indexOf('\r') >= 0) {
throw new ZygoteStartFailedEx("Embedded carriage returns not allowed");
+ } else if (arg.indexOf('\u0000') >= 0) {
+ throw new ZygoteStartFailedEx("Embedded nulls not allowed");
}
}
@@ -965,6 +967,14 @@ public class ZygoteProcess {
return true;
}
+ for (/* NonNull */ String s : mApiDenylistExemptions) {
+ // indexOf() is intrinsified and faster than contains().
+ if (s.indexOf('\n') >= 0 || s.indexOf('\r') >= 0 || s.indexOf('\u0000') >= 0) {
+ Slog.e(LOG_TAG, "Failed to set API denylist exemptions: Bad character");
+ mApiDenylistExemptions = Collections.emptyList();
+ return false;
+ }
+ }
try {
state.mZygoteOutputWriter.write(Integer.toString(mApiDenylistExemptions.size() + 1));
state.mZygoteOutputWriter.newLine();