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
ok phessler, millert, miod, deraadt
-/* $OpenBSD: citrus_utf8.c,v 1.2 2010/07/29 00:50:10 stsp Exp $ */
+/* $OpenBSD: citrus_utf8.c,v 1.3 2010/08/05 17:13:53 stsp Exp $ */
/*-
* Copyright (c) 2002-2004 Tim J. Robbins
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;