Ignore default-shell (and use /bin/sh) if it invalid not just if it is

tmux itself, also refuse to set the option to something invalid in the
first place. GitHub issue 2120.
This commit is contained in:
nicm
2020-03-17 11:10:12 +00:00
parent fb396286ff
commit 115bb33257
5 changed files with 15 additions and 6 deletions

View File

@ -309,6 +309,13 @@ cmd_set_option_set(struct cmd *self, struct cmdq_item *item, struct options *oo,
old = xstrdup(options_get_string(oo, oe->name));
options_set_string(oo, oe->name, append, "%s", value);
new = options_get_string(oo, oe->name);
if (strcmp(oe->name, "default-shell") == 0 &&
!checkshell(new)) {
options_set_string(oo, oe->name, 0, "%s", old);
free(old);
cmdq_error(item, "not a suitable shell: %s", value);
return (-1);
}
if (oe->pattern != NULL && fnmatch(oe->pattern, new, 0) != 0) {
options_set_string(oo, oe->name, 0, "%s", old);
free(old);