citrus: Avoid invalid code points.
From the OpenBSD log: The UTF-8 decoder should not accept byte sequences which decode to unicode code positions U+D800 to U+DFFF (UTF-16 surrogates), U+FFFE, and U+FFFF. http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 http://unicode.org/faq/utf_bom.html#utf8-4 Reported by: Stefan Sperling Obtained from: OpenBSD MFC after: 5 days
This commit is contained in:
parent
368f6e2f2f
commit
97ecaa8907
@ -203,6 +203,14 @@ _UTF8_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n,
|
||||
errno = EILSEQ;
|
||||
return ((size_t)-1);
|
||||
}
|
||||
if ((wch >= 0xd800 && wch <= 0xdfff) ||
|
||||
wch == 0xfffe || wch == 0xffff) {
|
||||
/*
|
||||
* Malformed input; invalid code points.
|
||||
*/
|
||||
errno = EILSEQ;
|
||||
return ((size_t)-1);
|
||||
}
|
||||
if (pwc != NULL)
|
||||
*pwc = wch;
|
||||
us->want = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user