summaryrefslogtreecommitdiffstats
path: root/cmd-new-session.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-04-06 21:51:31 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-04-06 21:51:31 +0000
commitec89eb955236f91e63febe1764123e605641fc52 (patch)
treec81e8a37c4625857f084ffdf70efba82fe715df3 /cmd-new-session.c
parentc8a14def9f2273c13d081c891d76e5f32323fc40 (diff)
Change so that an empty session name always means the current sessions
even if given with, for example, -t '', and explicitly forbid empty session names and those containing a : when they are created.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r--cmd-new-session.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c
index fc847bd2..5eaa5393 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -68,9 +68,15 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
u_int sx, sy, i;
newname = args_get(args, 's');
- if (newname != NULL && session_find(newname) != NULL) {
- ctx->error(ctx, "duplicate session: %s", newname);
- return (-1);
+ if (newname != NULL) {
+ if (!session_check_name(newname)) {
+ ctx->error(ctx, "bad session name: %s", newname);
+ return (-1);
+ }
+ if (session_find(newname) != NULL) {
+ ctx->error(ctx, "duplicate session: %s", newname);
+ return (-1);
+ }
}
target = args_get(args, 't');