[pve-devel] [PATCH vncterm 2/3] bound check utf8 characters
Dominik Csapak
d.csapak at proxmox.com
Tue Feb 28 12:06:43 CET 2017
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 <d.csapak at proxmox.com>
---
vncterm.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/vncterm.c b/vncterm.c
index baaa379..cc61293 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;
}
--
2.1.4
More information about the pve-devel
mailing list