Loading core/java/android/os/ZygoteProcess.java +15 −6 Original line number Original line Diff line number Diff line Loading @@ -237,6 +237,15 @@ public class ZygoteProcess { ZygoteState zygoteState, ArrayList<String> args) ZygoteState zygoteState, ArrayList<String> args) throws ZygoteStartFailedEx { throws ZygoteStartFailedEx { 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.SystemZygoteInit.readArgumentList() * See com.android.internal.os.SystemZygoteInit.readArgumentList() * Presently the wire format to the zygote process is: * Presently the wire format to the zygote process is: Loading @@ -253,13 +262,8 @@ public class ZygoteProcess { writer.write(Integer.toString(args.size())); writer.write(Integer.toString(args.size())); writer.newLine(); writer.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"); } writer.write(arg); writer.write(arg); writer.newLine(); writer.newLine(); } } Loading @@ -268,11 +272,16 @@ public class ZygoteProcess { // Should there be a timeout on this? // Should there be a timeout on this? Process.ProcessStartResult result = new Process.ProcessStartResult(); Process.ProcessStartResult result = new Process.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 = inputStream.readInt(); result.pid = inputStream.readInt(); result.usingWrapper = inputStream.readBoolean(); if (result.pid < 0) { if (result.pid < 0) { throw new ZygoteStartFailedEx("fork() failed"); throw new ZygoteStartFailedEx("fork() failed"); } } result.usingWrapper = inputStream.readBoolean(); return result; return result; } catch (IOException ex) { } catch (IOException ex) { zygoteState.close(); zygoteState.close(); Loading Loading
core/java/android/os/ZygoteProcess.java +15 −6 Original line number Original line Diff line number Diff line Loading @@ -237,6 +237,15 @@ public class ZygoteProcess { ZygoteState zygoteState, ArrayList<String> args) ZygoteState zygoteState, ArrayList<String> args) throws ZygoteStartFailedEx { throws ZygoteStartFailedEx { 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.SystemZygoteInit.readArgumentList() * See com.android.internal.os.SystemZygoteInit.readArgumentList() * Presently the wire format to the zygote process is: * Presently the wire format to the zygote process is: Loading @@ -253,13 +262,8 @@ public class ZygoteProcess { writer.write(Integer.toString(args.size())); writer.write(Integer.toString(args.size())); writer.newLine(); writer.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"); } writer.write(arg); writer.write(arg); writer.newLine(); writer.newLine(); } } Loading @@ -268,11 +272,16 @@ public class ZygoteProcess { // Should there be a timeout on this? // Should there be a timeout on this? Process.ProcessStartResult result = new Process.ProcessStartResult(); Process.ProcessStartResult result = new Process.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 = inputStream.readInt(); result.pid = inputStream.readInt(); result.usingWrapper = inputStream.readBoolean(); if (result.pid < 0) { if (result.pid < 0) { throw new ZygoteStartFailedEx("fork() failed"); throw new ZygoteStartFailedEx("fork() failed"); } } result.usingWrapper = inputStream.readBoolean(); return result; return result; } catch (IOException ex) { } catch (IOException ex) { zygoteState.close(); zygoteState.close(); Loading