Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6b044ae authored by Narayan Kamath's avatar Narayan Kamath
Browse files

Fix a couple of issues with system_server forking.

- Remove the obsolete --runtime-init arg. its prescence
  was preventing other arguments from being parsed.

- Be stricter about unparsed args - throw if we see arguments
  we don't expect. This was already implemented but broken
  (probably implemented by a crap programmer).

bug: 19378905
Change-Id: Id8b6158db7ef6368dd13ae61f591cdf2b278dfd1
parent b4a5c04c
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -399,7 +399,7 @@ class ZygoteConnection {
                throws IllegalArgumentException {
            int curArg = 0;

            boolean seenRuntimeArgs = true;
            boolean seenRuntimeArgs = false;

            for ( /* curArg */ ; curArg < args.length; curArg++) {
                String arg = args[curArg];
@@ -533,14 +533,18 @@ class ZygoteConnection {
                }
            }

            if (abiListQuery) {
                if (args.length - curArg > 0) {
                    throw new IllegalArgumentException("Unexpected arguments after --query-abi-list.");
                }
            } else {
                if (!seenRuntimeArgs) {
                    throw new IllegalArgumentException("Unexpected argument : " + args[curArg]);
                }

                remainingArgs = new String[args.length - curArg];

            System.arraycopy(args, curArg, remainingArgs, 0,
                    remainingArgs.length);
                System.arraycopy(args, curArg, remainingArgs, 0, remainingArgs.length);
            }
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -504,8 +504,8 @@ public class ZygoteInit {
            "--setgid=1000",
            "--setgroups=1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1018,1032,3001,3002,3003,3006,3007",
            "--capabilities=" + capabilities + "," + capabilities,
            "--runtime-init",
            "--nice-name=system_server",
            "--runtime-args",
            "com.android.server.SystemServer",
        };
        ZygoteConnection.Arguments parsedArgs = null;