From: Dominik Csapak Date: Tue, 28 Feb 2017 11:06:43 +0000 (+0100) Subject: bound check utf8 characters X-Git-Url: https://git.proxmox.com/?p=vncterm.git;a=commitdiff_plain;h=3d0dbf7c0e96b949d1f682bc02ce9500c136ae18;ds=sidebyside bound check utf8 characters since we load the fontmap from psf1 font files, we only have characters for a maximum codepoint of 0xFFFF, so we save the char in an unsigned short (16bit) but we decode up to 6 bytes of utf8 so we have to correctly bound check the assignment, else we can get garbled characters on the terminal Signed-off-by: Dominik Csapak --- diff --git a/vncterm.c b/vncterm.c index baaa379..3ca00ba 100644 --- a/vncterm.c +++ b/vncterm.c @@ -1790,7 +1790,11 @@ vncterm_puts (vncTerm *vt, const char *buf, int len) vt->utf_char = (vt->utf_char << 6) | (c & 0x3f); vt->utf_count--; if (vt->utf_count == 0) { - tc = vt->utf_char; + if (vt->utf_char <= USHRT_MAX) { + tc = vt->utf_char; + } else { + tc = 0; + } } else { continue; }