[pve-devel] [PATCH spiceterm 1/2] check range for utf8 characters

Dominik Csapak d.csapak at proxmox.com
Tue Feb 28 12:06:38 CET 2017


since we load the font from psf1 files, the highest utf8 codepoint we
have a fontmap for is 0xFFFF, so we use an unsigned short for the
character

but since we parse utf8 for up to 6 bytes we have to check the range, or
else we can get garbled output

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 spiceterm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/spiceterm.c b/spiceterm.c
index 532bb13..bcb38c6 100644
--- a/spiceterm.c
+++ b/spiceterm.c
@@ -1232,7 +1232,11 @@ spiceterm_puts(spiceTerm *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 <= G_MAXUINT16) {
+			    tc = vt->utf_char;
+			} else {
+			    tc = 0;
+			}
                     } else {
                         continue;
                     }
-- 
2.1.4





More information about the pve-devel mailing list