From 81eb7d7e4bc4f96ef228f474ba798cddebe2bedc Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 9 Aug 2015 10:36:25 +0000 Subject: [PATCH] Readd checking utf16 surrogates that are invalid in utf8 --- lib/libc/locale/utf8.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/libc/locale/utf8.c b/lib/libc/locale/utf8.c index 02b1ccc936f..11e7825ae03 100644 --- a/lib/libc/locale/utf8.c +++ b/lib/libc/locale/utf8.c @@ -193,6 +193,13 @@ _UTF8_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, errno = EILSEQ; return ((size_t)-1); } + if (wch >= 0xd800 && wch <= 0xdfff) { + /* + * Malformed input; invalid code points. + */ + errno = EILSEQ; + return ((size_t)-1); + } if (pwc != NULL) *pwc = wch; us->want = 0;