diff options
author | nicm <nicm> | 2017-08-29 09:18:48 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-08-29 09:18:48 +0000 |
commit | 9852bd743c9bf1029990538f2d89cfa1450fb54c (patch) | |
tree | f3cdc3d926bee3cf772b605043111104fc6d9a89 | |
parent | fe4467ad2bf7b37a12330ed0a147e7230d60179a (diff) | |
download | rtmux-9852bd743c9bf1029990538f2d89cfa1450fb54c.tar.gz rtmux-9852bd743c9bf1029990538f2d89cfa1450fb54c.tar.bz2 rtmux-9852bd743c9bf1029990538f2d89cfa1450fb54c.zip |
Check for complete keys before escape prefix, allows keys to be defined
with a leading escape. GitHub issue 1048.
-rw-r--r-- | server-fn.c | 2 | ||||
-rw-r--r-- | tty-keys.c | 19 |
2 files changed, 12 insertions, 9 deletions
diff --git a/server-fn.c b/server-fn.c index 1bd727d4..f5ede2c2 100644 --- a/server-fn.c +++ b/server-fn.c @@ -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); @@ -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. |