mirror of
https://github.com/tmux/tmux.git
synced 2024-11-18 10:28:54 +00:00
Forbid empty session names, GitHub issue 2758.
This commit is contained in:
parent
1d4296f17f
commit
35c2958ae4
@ -102,6 +102,11 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if (tmp != NULL) {
|
||||
name = format_single(item, tmp, c, NULL, NULL, NULL);
|
||||
newname = session_check_name(name);
|
||||
if (newname == NULL) {
|
||||
cmdq_error(item, "invalid session: %s", name);
|
||||
free(name);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
free(name);
|
||||
}
|
||||
if (args_has(args, 'A')) {
|
||||
@ -134,8 +139,14 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
prefix = xstrdup(sg->name);
|
||||
else if (groupwith != NULL)
|
||||
prefix = xstrdup(groupwith->name);
|
||||
else
|
||||
else {
|
||||
prefix = session_check_name(group);
|
||||
if (prefix == NULL) {
|
||||
cmdq_error(item, "invalid session group: %s",
|
||||
group);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Set -d if no client. */
|
||||
|
@ -53,6 +53,11 @@ cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
tmp = format_single_from_target(item, args->argv[0]);
|
||||
newname = session_check_name(tmp);
|
||||
if (newname == NULL) {
|
||||
cmdq_error(item, "invalid session: %s", tmp);
|
||||
free(tmp);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
free(tmp);
|
||||
if (strcmp(newname, s->name) == 0) {
|
||||
free(newname);
|
||||
|
Loading…
Reference in New Issue
Block a user