diff options
author | Anthony J. Bentley <bentley@cvs.openbsd.org> | 2015-10-13 02:17:47 +0000 |
---|---|---|
committer | Anthony J. Bentley <bentley@cvs.openbsd.org> | 2015-10-13 02:17:47 +0000 |
commit | 0246baba0017fb64883f9658423f80606c6d513f (patch) | |
tree | d01de0a2b30561c0d4b6bf6bb6ea19517c73dbd3 /lib | |
parent | 294189c6a84d22db437501a631394b2ded5bac99 (diff) |
Tighten the ranges in wcrtomb(3).
By definition, the range of valid Unicode code points is the union of
U+0000..U+D7FF and U+E000..U+10FFFF (see Unicode 8.0.0, chapter 3.9).
In UTF-16, the encoded values that would represent U+D800..U+DFFF are
used for surrogate pairs. UTF-8 has no concept of surrogate pairs;
attempting to treat them as regular code points violates the standard
and makes no sense besides.
ok stsp@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/citrus/citrus_utf8.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/citrus/citrus_utf8.c b/lib/libc/citrus/citrus_utf8.c index 42ee2a36300..e1d83ced8a2 100644 --- a/lib/libc/citrus/citrus_utf8.c +++ b/lib/libc/citrus/citrus_utf8.c @@ -1,4 +1,4 @@ -/* $OpenBSD: citrus_utf8.c,v 1.13 2015/10/12 17:50:51 schwarze Exp $ */ +/* $OpenBSD: citrus_utf8.c,v 1.14 2015/10/13 02:17:46 bentley Exp $ */ /*- * Copyright (c) 2002-2004 Tim J. Robbins @@ -292,7 +292,7 @@ _citrus_utf8_ctype_wcrtomb(char * __restrict s, return (1); } - if (wc < 0 || wc > 0x10ffff) { + if (wc < 0 || (wc > 0xd7ff && wc < 0xe000) || wc > 0x10ffff) { errno = EILSEQ; return ((size_t)-1); } |