]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
lib/vsprintf: print '?' for illegal Unicode sequence
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Fri, 15 Feb 2019 21:20:53 +0000 (22:20 +0100)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Sat, 16 Feb 2019 14:42:20 +0000 (15:42 +0100)
Commit 0e66c10a7d80 ("lib: vsprintf: avoid overflow printing UTF16
strings") broke the Unicode unit tests: an illegal UTF16 code point
should be printed as '?'.

Fixes: 0e66c10a7d80 ("lib: vsprintf: avoid overflow printing UTF16 strings")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/vsprintf.c

index de5db1aa5c7f4eef2d8a6aebecef23c05fb43fe5..1b6c154d8d722215767a7cef1c850850dda6088a 100644 (file)
@@ -288,6 +288,8 @@ static char *string16(char *buf, char *end, u16 *s, int field_width,
        for (i = 0; i < len && buf + utf16_utf8_strnlen(str, 1) <= end; ++i) {
                s32 s = utf16_get(&str);
 
+               if (s < 0)
+                       s = '?';
                utf8_put(s, &buf);
        }
        for (; len < field_width; --field_width)