summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2014-04-29 15:25:57 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2014-04-29 15:25:57 +0000
commit97ecaa89074fda0fa805393ac066bf59a1778f55 (patch)
tree29bd5b654014f9c70803905b3009adcb132d7578 /lib/libc
parent368f6e2f2f77a00689f283d3ce3eeedaefac95ca (diff)
downloadsrc-test2-97ecaa89074fda0fa805393ac066bf59a1778f55.tar.gz
src-test2-97ecaa89074fda0fa805393ac066bf59a1778f55.zip
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/locale/utf8.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/libc/locale/utf8.c b/lib/libc/locale/utf8.c
index 40f0e1701bd5..ef5784a287d5 100644
--- a/lib/libc/locale/utf8.c
+++ b/lib/libc/locale/utf8.c
@@ -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;