diff mbox series

[U-Boot,1/2] lib/vsprintf: print '?' for illegal Unicode sequence

Message ID 20190215225902.22126-2-xypron.glpk@gmx.de
State Accepted
Commit 60c4454ddb98cb3e194483fb66652e0bb2552761
Delegated to: Tom Rini
Headers show
Series lib/vsprintf: print '?' for illegal Unicode sequence | expand

Commit Message

Heinrich Schuchardt Feb. 15, 2019, 10:59 p.m. UTC
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 | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index de5db1aa5c..1b6c154d8d 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -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)