diff options
author | Ran Benita <ran234@gmail.com> | 2018-06-23 22:00:19 +0300 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2018-06-23 22:53:42 +0300 |
commit | 5cee660f692b67fdb2ce677fc516382bf0e93af1 (patch) | |
tree | c5fa7cfb94875e14da00dff1d68207fd9c2044dd /src/utf8.c | |
parent | b63196e91e7d78e88a9012f3f44152eeef5358cf (diff) | |
download | xorg-lib-libxkbcommon-5cee660f692b67fdb2ce677fc516382bf0e93af1.tar.gz |
keysym-utf: reject out-of-range Unicode codepoints in xkb_keysym_to_utf{8,32}
It used to be UTF-8 was defined for inputs > 0x10FFFF, but nowadays
that's the maximum and a codepoint is encoded up to 4 bytes, not 6.
Fixes: https://github.com/xkbcommon/libxkbcommon/issues/58
Fixes: https://github.com/xkbcommon/libxkbcommon/issues/59
Reported-by: @andrecbarros
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/utf8.c')
-rw-r--r-- | src/utf8.c | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -49,17 +49,13 @@ utf32_to_utf8(uint32_t unichar, char *buffer) length = 3; head = 0xe0; } - else if (unichar <= 0x1fffff) { + else if (unichar <= 0x10ffff) { length = 4; head = 0xf0; } - else if (unichar <= 0x3ffffff) { - length = 5; - head = 0xf8; - } else { - length = 6; - head = 0xfc; + buffer[0] = '\0'; + return 0; } for (count = length - 1, shift = 0; count > 0; count--, shift += 6) |