Commit ef6b25b3 authored by topjohnwu's avatar topjohnwu

Duplicate the command string

parent ff48996b
...@@ -585,7 +585,8 @@ static void fork_for_samsung(void) ...@@ -585,7 +585,8 @@ static void fork_for_samsung(void)
} }
} }
static void concat_commands(char* command, int argc, char *argv[]) { static char *concat_commands(int argc, char *argv[]) {
char command[ARG_MAX];
int i; int i;
command[0] = '\0'; command[0] = '\0';
for (i = optind - 1; i < argc; ++i) { for (i = optind - 1; i < argc; ++i) {
...@@ -594,6 +595,7 @@ static void concat_commands(char* command, int argc, char *argv[]) { ...@@ -594,6 +595,7 @@ static void concat_commands(char* command, int argc, char *argv[]) {
else else
sprintf(command, "%s", argv[i]); sprintf(command, "%s", argv[i]);
} }
return strdup(command);
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
...@@ -720,9 +722,7 @@ int su_main_nodaemon(int argc, char **argv) { ...@@ -720,9 +722,7 @@ int su_main_nodaemon(int argc, char **argv) {
switch(c) { switch(c) {
case 'c': case 'c':
ctx.to.shell = DEFAULT_SHELL; ctx.to.shell = DEFAULT_SHELL;
char command[ARG_MAX]; ctx.to.command = concat_commands(argc, argv);
concat_commands(command, argc, argv);
ctx.to.command = command;
optind = argc; optind = argc;
break; break;
case 'h': case 'h':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment