tokenize: strdup() each individual argv

Instead of referencing the un-tokenized “raw” command string, strdup()
each argv. This way, the input string can be ‘const’.
This commit is contained in:
Daniel Eklöf 2021-06-20 14:17:31 +02:00
parent 7632e16e36
commit 42ec264075
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 56 additions and 38 deletions

View file

@ -293,9 +293,7 @@ slave_spawn(int ptmx, int argc, const char *cwd, char *const *argv,
char **shell_argv = NULL;
if (argc == 0) {
char *shell_copy = xstrdup(conf_shell);
if (!tokenize_cmdline(shell_copy, &_shell_argv)) {
free(shell_copy);
if (!tokenize_cmdline(conf_shell, &_shell_argv)) {
(void)!write(fork_pipe[1], &errno, sizeof(errno));
_exit(0);
}