summaryrefslogtreecommitdiff
path: root/trust/utf8.c
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2016-09-22 14:11:16 +0200
committerDaiki Ueno <ueno@gnu.org>2016-11-28 10:34:21 +0100
commit1d2276dc20153eb513d67aeb3464cf0c1edf6d38 (patch)
tree46804ec127e3ad35f00ddfe4fb41802e34dc4b2f /trust/utf8.c
parent3846526ee94f6b4bbc0ea07d9d3cb72ed9f92707 (diff)
trust: Reject invalid UTF-8 input
Merge changes from utf8.c in FreeBSD's libc: https://svnweb.freebsd.org/base/head/lib/libc/locale/utf8.c?revision=290494&view=markup#l196 https://bugzilla.redhat.com/show_bug.cgi?id=985449
Diffstat (limited to 'trust/utf8.c')
-rw-r--r--trust/utf8.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/trust/utf8.c b/trust/utf8.c
index b94c3e7..72280b5 100644
--- a/trust/utf8.c
+++ b/trust/utf8.c
@@ -156,6 +156,12 @@ utf8_to_uchar (const char *str,
*/
return -1;
}
+ if ((uch >= 0xd800 && uch <= 0xdfff) || uch > 0x10ffff) {
+ /*
+ * Malformed input; invalid code points.
+ */
+ return -1;
+ }
*uc = uch;
return want;