Merge "Process: Fix communication with zygote." into klp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6829cf28e2
@@ -495,6 +495,15 @@ public class Process {
|
|||||||
openZygoteSocketIfNeeded();
|
openZygoteSocketIfNeeded();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Throw early if any of the arguments are malformed. This means we can
|
||||||
|
// avoid writing a partial response to the zygote.
|
||||||
|
int sz = args.size();
|
||||||
|
for (int i = 0; i < sz; i++) {
|
||||||
|
if (args.get(i).indexOf('\n') >= 0) {
|
||||||
|
throw new ZygoteStartFailedEx("embedded newlines not allowed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See com.android.internal.os.ZygoteInit.readArgumentList()
|
* See com.android.internal.os.ZygoteInit.readArgumentList()
|
||||||
* Presently the wire format to the zygote process is:
|
* Presently the wire format to the zygote process is:
|
||||||
@@ -509,13 +518,8 @@ public class Process {
|
|||||||
sZygoteWriter.write(Integer.toString(args.size()));
|
sZygoteWriter.write(Integer.toString(args.size()));
|
||||||
sZygoteWriter.newLine();
|
sZygoteWriter.newLine();
|
||||||
|
|
||||||
int sz = args.size();
|
|
||||||
for (int i = 0; i < sz; i++) {
|
for (int i = 0; i < sz; i++) {
|
||||||
String arg = args.get(i);
|
String arg = args.get(i);
|
||||||
if (arg.indexOf('\n') >= 0) {
|
|
||||||
throw new ZygoteStartFailedEx(
|
|
||||||
"embedded newlines not allowed");
|
|
||||||
}
|
|
||||||
sZygoteWriter.write(arg);
|
sZygoteWriter.write(arg);
|
||||||
sZygoteWriter.newLine();
|
sZygoteWriter.newLine();
|
||||||
}
|
}
|
||||||
@@ -524,11 +528,15 @@ public class Process {
|
|||||||
|
|
||||||
// Should there be a timeout on this?
|
// Should there be a timeout on this?
|
||||||
ProcessStartResult result = new ProcessStartResult();
|
ProcessStartResult result = new ProcessStartResult();
|
||||||
|
// Always read the entire result from the input stream to avoid leaving
|
||||||
|
// bytes in the stream for future process starts to accidentally stumble
|
||||||
|
// upon.
|
||||||
result.pid = sZygoteInputStream.readInt();
|
result.pid = sZygoteInputStream.readInt();
|
||||||
|
result.usingWrapper = sZygoteInputStream.readBoolean();
|
||||||
|
|
||||||
if (result.pid < 0) {
|
if (result.pid < 0) {
|
||||||
throw new ZygoteStartFailedEx("fork() failed");
|
throw new ZygoteStartFailedEx("fork() failed");
|
||||||
}
|
}
|
||||||
result.usingWrapper = sZygoteInputStream.readBoolean();
|
|
||||||
return result;
|
return result;
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user