summaryrefslogtreecommitdiffstats
path: root/key-string.c
diff options
context:
space:
mode:
authornicm <nicm>2015-11-14 10:56:31 +0000
committernicm <nicm>2015-11-14 10:56:31 +0000
commit64333e3ef89047d1c09cdc5053af647dbd8344da (patch)
tree99b3efed938dd8499c791ce04830ec738b87041c /key-string.c
parentc56b81a2ce815f6d289232f20bb6e07cfd0e36ec (diff)
Be more strict about invalid UTF-8.
Diffstat (limited to 'key-string.c')
-rw-r--r--key-string.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/key-string.c b/key-string.c
index c2230218..81d014ac 100644
--- a/key-string.c
+++ b/key-string.c
@@ -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);
}