From 64333e3ef89047d1c09cdc5053af647dbd8344da Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 14 Nov 2015 10:56:31 +0000 Subject: Be more strict about invalid UTF-8. --- key-string.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'key-string.c') 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); } -- cgit From dab63b029e94dcabe335abf7f89c66c28486a542 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 14 Nov 2015 10:57:59 +0000 Subject: Couple of assignments to remove compiler warnings. --- key-string.c | 1 + 1 file changed, 1 insertion(+) (limited to 'key-string.c') diff --git a/key-string.c b/key-string.c index 81d014ac..ad7cbf50 100644 --- a/key-string.c +++ b/key-string.c @@ -176,6 +176,7 @@ key_string_lookup_string(const char *string) if (utf8_open(&ud, (u_char)*string)) { if (strlen(string) != ud.size) return (KEYC_NONE); + more = 1; for (i = 1; i < ud.size; i++) more = utf8_append(&ud, (u_char)string[i]); if (more != 0) -- cgit