From cd833afad15fedab2ca1f2c39ea2d450cd41c2df Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 12 Jan 2010 15:18:32 -0800 Subject: [PATCH] android-2.1_r1 snapshot --- pppd/main.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/pppd/main.c b/pppd/main.c index adb57f1..64efefe 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -360,16 +360,39 @@ main(argc, argv) */ tty_init(); + progname = *argv; + #ifdef ANDROID_CHANGES { extern void pppox_init(); pppox_init(); privileged = 1; } + { + char *envargs = getenv("envargs"); + if (envargs) { + int i; + /* Decode the arguments in-place and count the number of them. + * They were hex encoded using [A-P] instead of [0-9A-F]. */ + for (argc = 0, i = 0; envargs[i] && envargs[i + 1]; i += 2) { + char c = ((envargs[i] - 'A') << 4) + (envargs[i + 1] - 'A'); + if (c == 0) { + ++argc; + } + envargs[i / 2 + 1] = c; + } + if (argc == 0 || (argv = malloc(sizeof(char *) * argc)) == NULL) { + fatal("Failed to parse envargs!"); + } + for (envargs[0] = 0, i = 0; i < argc; ++envargs) { + if (envargs[0] == 0) { + argv[i++] = &envargs[1]; + } + } + } + } #endif - progname = *argv; - /* * Parse, in order, the system options file, the user's options file, * and the command line arguments. -- 2.11.0