summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2024-08-23 13:25:40 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2024-08-23 13:25:40 +0000
commit02b051718c2c3ce5b00da94950f342f0fb00b8d8 (patch)
tree315043dc7ed45a8783dc2c665c0a33cf944ebe50
parent88a374a4ea682237847f106063cfd5c9413a7e46 (diff)
Ignore internal function keys if they have not got an entry in the key
table.
-rw-r--r--usr.bin/tmux/input-keys.c14
-rw-r--r--usr.bin/tmux/key-string.c4
-rw-r--r--usr.bin/tmux/tmux.h5
3 files changed, 15 insertions, 8 deletions
diff --git a/usr.bin/tmux/input-keys.c b/usr.bin/tmux/input-keys.c
index 348b0987bc7..d8dc2aa2127 100644
--- a/usr.bin/tmux/input-keys.c
+++ b/usr.bin/tmux/input-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input-keys.c,v 1.96 2024/08/21 04:55:57 nicm Exp $ */
+/* $OpenBSD: input-keys.c,v 1.97 2024/08/23 13:25:39 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -499,9 +499,8 @@ input_key_vt10x(struct bufferevent *bev, key_code key)
return (0);
}
- onlykey = key & KEYC_MASK_KEY;
-
/* Prevent TAB and RET from being swallowed by C0 remapping logic. */
+ onlykey = key & KEYC_MASK_KEY;
if (onlykey == '\r' || onlykey == '\t')
key &= ~KEYC_CTRL;
@@ -594,7 +593,7 @@ input_key(struct screen *s, struct bufferevent *bev, key_code key)
/* Is this backtab? */
if ((key & KEYC_MASK_KEY) == KEYC_BTAB) {
- if (s->mode & EXTENDED_KEY_MODES) {
+ if ((s->mode & EXTENDED_KEY_MODES) != 0) {
/* When in xterm extended mode, remap into S-Tab. */
key = '\011' | (key & ~KEYC_MASK_KEY) | KEYC_SHIFT;
} else {
@@ -651,6 +650,13 @@ input_key(struct screen *s, struct bufferevent *bev, key_code key)
return (0);
}
+ /* Ignore internal function key codes. */
+ if ((key >= KEYC_BASE && key < KEYC_BASE_END) ||
+ (key >= KEYC_USER && key < KEYC_USER_END)) {
+ log_debug("%s: ignoring key 0x%llx", __func__, key);
+ return (0);
+ }
+
/*
* No builtin key sequence; construct an extended key sequence
* depending on the client mode.
diff --git a/usr.bin/tmux/key-string.c b/usr.bin/tmux/key-string.c
index 856c974fb5a..323600841f4 100644
--- a/usr.bin/tmux/key-string.c
+++ b/usr.bin/tmux/key-string.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key-string.c,v 1.74 2024/08/22 09:05:51 nicm Exp $ */
+/* $OpenBSD: key-string.c,v 1.75 2024/08/23 13:25:39 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -410,7 +410,7 @@ key_string_lookup_key(key_code key, int with_flags)
s = "MouseMoveBorder";
goto append;
}
- if (key >= KEYC_USER && key < KEYC_USER + KEYC_NUSER) {
+ if (key >= KEYC_USER && key < KEYC_USER_END) {
snprintf(tmp, sizeof tmp, "User%u", (u_int)(key - KEYC_USER));
strlcat(out, tmp, sizeof out);
goto out;
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 7c6f7c7c84b..2faaf53fd55 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.1221 2024/08/21 04:17:09 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1222 2024/08/23 13:25:39 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -125,6 +125,7 @@ struct winlink;
*/
#define KEYC_BASE 0x0000000010e000ULL
#define KEYC_USER 0x0000000010f000ULL
+#define KEYC_USER_END (KEYC_USER + KEYC_NUSER)
/* Key modifier bits. */
#define KEYC_META 0x00100000000000ULL
@@ -159,7 +160,7 @@ struct winlink;
(((key) & KEYC_MASK_KEY) < KEYC_BASE || \
((key) & KEYC_MASK_KEY) >= KEYC_BASE_END) && \
(((key) & KEYC_MASK_KEY) < KEYC_USER || \
- ((key) & KEYC_MASK_KEY) >= KEYC_USER + KEYC_NUSER))
+ ((key) & KEYC_MASK_KEY) >= KEYC_USER_END))
/* Multiple click timeout. */
#define KEYC_CLICK_TIMEOUT 300