diff --git a/libqrexec/exec.c b/libqrexec/exec.c index 164524d9..d641b3b8 100644 --- a/libqrexec/exec.c +++ b/libqrexec/exec.c @@ -52,27 +52,28 @@ void exec_qubes_rpc_if_requested(const char *prog, char *const envp[]) { char *prog_copy; char *tok, *savetok; char *argv[16]; // right now 6 are used, but allow future extensions - size_t i = 0; + size_t i = 1; if (prog[RPC_REQUEST_COMMAND_LEN] != ' ') { LOG(ERROR, "\"" RPC_REQUEST_COMMAND "\" not followed by space"); _exit(126); } - prog_copy = strdup(prog); + prog_copy = strdup(prog + RPC_REQUEST_COMMAND_LEN + 1); if (!prog_copy) { PERROR("strdup"); _exit(QREXEC_EXIT_PROBLEM); } tok=strtok_r(prog_copy, " ", &savetok); - do { + while (tok != NULL) { if (i >= sizeof(argv)/sizeof(argv[0])-1) { LOG(ERROR, "To many arguments to %s", RPC_REQUEST_COMMAND); _exit(QREXEC_EXIT_PROBLEM); } argv[i++] = tok; - } while ((tok=strtok_r(NULL, " ", &savetok))); + tok=strtok_r(NULL, " ", &savetok); + } argv[i] = NULL; argv[0] = getenv("QREXEC_MULTIPLEXER_PATH");