summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/key-string.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2016-03-02 15:36:04 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2016-03-02 15:36:04 +0000
commit58e1679b6ddb893e7e057b491aac76757819f994 (patch)
tree9160603edcb49d2b7c1c991f82e444b1c12d42ab /usr.bin/tmux/key-string.c
parent0cd5b4650ef6c671175dd8c336f0b25caaf290da (diff)
Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the same as we drop invalid UTF-8. Suggested by schwarze@.
Diffstat (limited to 'usr.bin/tmux/key-string.c')
-rw-r--r--usr.bin/tmux/key-string.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/tmux/key-string.c b/usr.bin/tmux/key-string.c
index 3b3988bbf05..d930e4e446a 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.34 2016/01/19 15:59:12 nicm Exp $ */
+/* $OpenBSD: key-string.c,v 1.35 2016/03/02 15:36:02 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -149,6 +149,7 @@ key_string_lookup_string(const char *string)
struct utf8_data ud;
u_int i;
enum utf8_state more;
+ wchar_t wc;
/* Is this no key? */
if (strcasecmp(string, "None") == 0)
@@ -185,8 +186,9 @@ key_string_lookup_string(const char *string)
more = utf8_append(&ud, (u_char)string[i]);
if (more != UTF8_DONE)
return (KEYC_UNKNOWN);
- key = utf8_combine(&ud);
- return (key | modifiers);
+ if (utf8_combine(&ud, &wc) != UTF8_DONE)
+ return (KEYC_UNKNOWN);
+ return (wc | modifiers);
}
/* Otherwise look the key up in the table. */