diff options
author | Stefan Liebler <stli@linux.vnet.ibm.com> | 2016-05-25 17:18:06 +0200 |
---|---|---|
committer | Stefan Liebler <stli@linux.vnet.ibm.com> | 2016-05-25 17:18:06 +0200 |
commit | 7ab1de21067d72460ac14089bf6541b10fc14c80 (patch) | |
tree | 6d6951d561f7b01d791b7c29f394e2f374993985 /iconvdata/Makefile | |
parent | 8f25676c83eef5c85db98f9cf027890fbe810447 (diff) | |
download | glibc-7ab1de21067d72460ac14089bf6541b10fc14c80.zip glibc-7ab1de21067d72460ac14089bf6541b10fc14c80.tar.gz glibc-7ab1de21067d72460ac14089bf6541b10fc14c80.tar.bz2 |
Fix UTF-16 surrogate handling. [BZ #19727]
According to the latest Unicode standard, a conversion from/to UTF-xx has
to report an error if the character value is in range of an utf16 surrogate
(0xd800..0xdfff). See https://sourceware.org/ml/libc-help/2015-12/msg00015.html.
Thus this patch fixes this behaviour for converting from utf32 to internal and
from internal to utf8.
Furthermore the conversion from utf16 to internal does not report an error if the
input-stream consists of two low-surrogate values. If an uint16_t value is in the
range of 0xd800 .. 0xdfff, the next uint16_t value is checked, if it is in the
range of a low surrogate (0xdc00 .. 0xdfff). Afterwards these two uint16_t
values are interpreted as a high- and low-surrogates pair. But there is no test
if the first uint16_t value is really in the range of a high-surrogate
(0xd800 .. 0xdbff). If there would be two uint16_t values in the range of a low
surrogate, then they will be treated as a valid high- and low-surrogates pair.
This patch adds this test.
This patch also adds a new testcase, which checks UTF conversions with input
values in range of UTF16 surrogates. The test converts from UTF-xx to INTERNAL,
INTERNAL to UTF-xx and directly between UTF-xx to UTF-yy. The latter conversion
is needed because s390 has iconv-modules, which converts from/to UTF in one step.
The new testcase was tested on a s390, power and intel machine.
ChangeLog:
[BZ #19727]
* iconvdata/utf-16.c (BODY): Report an error if first word is not a
valid high surrogate.
* iconvdata/utf-32.c (BODY): Report an error if the value is in range
of an utf16 surrogate.
* iconv/gconv_simple.c (BODY): Likewise.
* iconvdata/bug-iconv12.c: New file.
* iconvdata/Makefile (tests): Add bug-iconv12.
rename test
Diffstat (limited to 'iconvdata/Makefile')
-rw-r--r-- | iconvdata/Makefile | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/iconvdata/Makefile b/iconvdata/Makefile index f9826b3..3df5aa4 100644 --- a/iconvdata/Makefile +++ b/iconvdata/Makefile @@ -68,7 +68,7 @@ modules.so := $(addsuffix .so, $(modules)) ifeq (yes,$(build-shared)) tests = bug-iconv1 bug-iconv2 tst-loading tst-e2big tst-iconv4 bug-iconv4 \ tst-iconv6 bug-iconv5 bug-iconv6 tst-iconv7 bug-iconv8 bug-iconv9 \ - bug-iconv10 bug-iconv11 + bug-iconv10 bug-iconv11 bug-iconv12 ifeq ($(have-thread-library),yes) tests += bug-iconv3 endif @@ -309,6 +309,8 @@ $(objpfx)tst-iconv7.out: $(objpfx)gconv-modules \ $(addprefix $(objpfx),$(modules.so)) $(objpfx)bug-iconv10.out: $(objpfx)gconv-modules \ $(addprefix $(objpfx),$(modules.so)) +$(objpfx)bug-iconv12.out: $(objpfx)gconv-modules \ + $(addprefix $(objpfx),$(modules.so)) $(objpfx)iconv-test.out: run-iconv-test.sh $(objpfx)gconv-modules \ $(addprefix $(objpfx),$(modules.so)) \ |