Skip to content

Commit

Permalink
Avoid pointlessly setting argv[0]
Browse files Browse the repository at this point in the history
It will just be overwritten later.  No functional change intended.
  • Loading branch information
DemiMarie committed Apr 28, 2024
1 parent 930b47d commit 696f831
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions libqrexec/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 696f831

Please sign in to comment.