summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/key-string.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-11-14 10:56:32 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-11-14 10:56:32 +0000
commitac7d76cc0157cf50290e3ed2c9cc3bb566586a16 (patch)
tree2ae3ea5fa2d90067278c3b9450dcce20ef6b779d /usr.bin/tmux/key-string.c
parent9b9826957255134c5f7ef1fa9b9d991ec0f5ff6c (diff)
Be more strict about invalid UTF-8.
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 61e70fe6273..838bfe64051 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.29 2015/11/12 22:04:37 nicm Exp $ */
+/* $OpenBSD: key-string.c,v 1.30 2015/11/14 10:56:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -144,7 +144,7 @@ key_string_lookup_string(const char *string)
static const char *other = "!#()+,-.0123456789:;<=>?'\r\t";
key_code key;
u_short u;
- int size;
+ int size, more;
key_code modifiers;
struct utf8_data ud;
u_int i;
@@ -177,7 +177,9 @@ key_string_lookup_string(const char *string)
if (strlen(string) != ud.size)
return (KEYC_NONE);
for (i = 1; i < ud.size; i++)
- utf8_append(&ud, (u_char)string[i]);
+ more = utf8_append(&ud, (u_char)string[i]);
+ if (more != 0)
+ return (KEYC_NONE);
key = utf8_combine(&ud);
return (key | modifiers);
}