summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-08-29 09:18:49 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-08-29 09:18:49 +0000
commitcda40602f91b133a818b52604234fb4658a6f5d0 (patch)
tree1faf0a40ca27a856c368d27da54b38515f22c22e /usr.bin
parent14477edaa57aecddd277fb7e9bb6d488def77b08 (diff)
Check for complete keys before escape prefix, allows keys to be defined
with a leading escape. GitHub issue 1048.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/server-fn.c4
-rw-r--r--usr.bin/tmux/tty-keys.c21
2 files changed, 14 insertions, 11 deletions
diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c
index 49e8e19585b..413bae44de9 100644
--- a/usr.bin/tmux/server-fn.c
+++ b/usr.bin/tmux/server-fn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-fn.c,v 1.110 2017/07/12 09:07:52 nicm Exp $ */
+/* $OpenBSD: server-fn.c,v 1.111 2017/08/29 09:18:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -164,7 +164,7 @@ server_lock_client(struct client *c)
return;
cmd = options_get_string(c->session->options, "lock-command");
- if (strlen(cmd) + 1 > MAX_IMSGSIZE - IMSG_HEADER_SIZE)
+ if (*cmd == '\0' || strlen(cmd) + 1 > MAX_IMSGSIZE - IMSG_HEADER_SIZE)
return;
tty_stop_tty(&c->tty);
diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c
index 03dd5baeef0..67acdef9fd3 100644
--- a/usr.bin/tmux/tty-keys.c
+++ b/usr.bin/tmux/tty-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty-keys.c,v 1.100 2017/08/27 08:33:55 nicm Exp $ */
+/* $OpenBSD: tty-keys.c,v 1.101 2017/08/29 09:18:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -595,7 +595,17 @@ tty_keys_next(struct tty *tty)
}
first_key:
- /* Handle keys starting with escape. */
+ /* Try to lookup complete key. */
+ n = tty_keys_next1(tty, buf, len, &key, &size, expired);
+ if (n == 0) /* found */
+ goto complete_key;
+ if (n == 1)
+ goto partial_key;
+
+ /*
+ * If not a complete key, look for key with an escape prefix (meta
+ * modifier).
+ */
if (*buf == '\033') {
/* Look for a key without the escape. */
n = tty_keys_next1(tty, buf + 1, len - 1, &key, &size, expired);
@@ -620,13 +630,6 @@ first_key:
goto partial_key;
}
- /* Try to lookup key. */
- n = tty_keys_next1(tty, buf, len, &key, &size, expired);
- if (n == 0) /* found */
- goto complete_key;
- if (n == 1)
- goto partial_key;
-
/*
* At this point, we know the key is not partial (with or without
* escape). So pass it through even if the timer has not expired.