olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1380680-17.patch

00db10
From dd5820453c8c8c6521e45e1cb229f70a5ab5f6b0 Mon Sep 17 00:00:00 2001
00db10
From: Stefan Liebler <stli@linux.vnet.ibm.com>
00db10
Date: Mon, 7 Nov 2016 17:45:56 +0100
00db10
Subject: [PATCH 17/17] Fix UTF-16 surrogate handling. [BZ #19727]
00db10
00db10
Upstream commit 7ab1de21067d72460ac14089bf6541b10fc14c80
00db10
00db10
According to the latest Unicode standard, a conversion from/to UTF-xx has
00db10
to report an error if the character value is in range of an utf16 surrogate
00db10
(0xd800..0xdfff). See https://sourceware.org/ml/libc-help/2015-12/msg00015.html.
00db10
Thus this patch fixes this behaviour for converting from utf32 to internal and
00db10
from internal to utf8.
00db10
00db10
Furthermore the conversion from utf16 to internal does not report an error if the
00db10
input-stream consists of two low-surrogate values. If an uint16_t value is in the
00db10
range of 0xd800 .. 0xdfff, the next uint16_t value is checked, if it is in the
00db10
range of a low surrogate (0xdc00 .. 0xdfff). Afterwards these two uint16_t
00db10
values are interpreted as a high- and low-surrogates pair. But there is no test
00db10
if the first uint16_t value is really in the range of a high-surrogate
00db10
(0xd800 .. 0xdbff). If there would be two uint16_t values in the range of a low
00db10
surrogate, then they will be treated as a valid high- and low-surrogates pair.
00db10
This patch adds this test.
00db10
00db10
This patch also adds a new testcase, which checks UTF conversions with input
00db10
values in range of UTF16 surrogates. The test converts from UTF-xx to INTERNAL,
00db10
INTERNAL to UTF-xx and directly between UTF-xx to UTF-yy. The latter conversion
00db10
is needed because s390 has iconv-modules, which converts from/to UTF in one step.
00db10
The new testcase was tested on a s390, power and intel machine.
00db10
00db10
ChangeLog:
00db10
00db10
	[BZ #19727]
00db10
	* iconvdata/utf-16.c (BODY): Report an error if first word is not a
00db10
	valid high surrogate.
00db10
	* iconvdata/utf-32.c (BODY): Report an error if the value is in range
00db10
	of an utf16 surrogate.
00db10
	* iconv/gconv_simple.c (BODY): Likewise.
00db10
	* iconvdata/bug-iconv12.c: New file.
00db10
	* iconvdata/Makefile (tests): Add bug-iconv12.
00db10
---
00db10
 iconv/gconv_simple.c    |   3 +-
00db10
 iconvdata/Makefile      |   4 +-
00db10
 iconvdata/bug-iconv12.c | 263 ++++++++++++++++++++++++++++++++++++++++++++++++
00db10
 iconvdata/utf-16.c      |  12 +++
00db10
 iconvdata/utf-32.c      |   3 +-
00db10
 5 files changed, 282 insertions(+), 3 deletions(-)
00db10
 create mode 100644 iconvdata/bug-iconv12.c
00db10
00db10
diff --git a/iconv/gconv_simple.c b/iconv/gconv_simple.c
00db10
index b9f846d..48932ee 100644
00db10
--- a/iconv/gconv_simple.c
00db10
+++ b/iconv/gconv_simple.c
00db10
@@ -888,7 +888,8 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
00db10
     if (__builtin_expect (wc < 0x80, 1))				      \
00db10
       /* It's an one byte sequence.  */					      \
00db10
       *outptr++ = (unsigned char) wc;					      \
00db10
-    else if (__builtin_expect (wc <= 0x7fffffff, 1))			      \
00db10
+    else if (__builtin_expect (wc <= 0x7fffffff				      \
00db10
+			       && (wc < 0xd800 || wc > 0xdfff), 1))	      \
00db10
       {									      \
00db10
 	size_t step;							      \
00db10
 	unsigned char *start;						      \
00db10
diff --git a/iconvdata/Makefile b/iconvdata/Makefile
00db10
index e2624de..0ec6755 100644
00db10
--- a/iconvdata/Makefile
00db10
+++ b/iconvdata/Makefile
00db10
@@ -68,7 +68,7 @@ include ../Makeconfig
00db10
 ifeq (yes,$(build-shared))
00db10
 tests = bug-iconv1 bug-iconv2 tst-loading tst-e2big tst-iconv4 bug-iconv4 \
00db10
 	tst-iconv6 bug-iconv5 bug-iconv6 tst-iconv7 bug-iconv8 bug-iconv9 \
00db10
-	bug-iconv10
00db10
+	bug-iconv10 bug-iconv12
00db10
 ifeq ($(have-thread-library),yes)
00db10
 tests += bug-iconv3
00db10
 endif
00db10
@@ -294,6 +294,8 @@ $(objpfx)bug-iconv5.out: $(objpfx)gconv-modules \
00db10
 			 $(addprefix $(objpfx),$(modules.so))
00db10
 $(objpfx)bug-iconv10.out: $(objpfx)gconv-modules \
00db10
 			  $(addprefix $(objpfx),$(modules.so))
00db10
+$(objpfx)bug-iconv12.out: $(objpfx)gconv-modules \
00db10
+			  $(addprefix $(objpfx),$(modules.so))
00db10
 $(objpfx)tst-loading.out: $(objpfx)gconv-modules \
00db10
 			  $(addprefix $(objpfx),$(modules.so))
00db10
 $(objpfx)tst-iconv4.out: $(objpfx)gconv-modules \
00db10
diff --git a/iconvdata/bug-iconv12.c b/iconvdata/bug-iconv12.c
00db10
new file mode 100644
00db10
index 0000000..49f5208
00db10
--- /dev/null
00db10
+++ b/iconvdata/bug-iconv12.c
00db10
@@ -0,0 +1,263 @@
00db10
+/* bug 19727: Testing UTF conversions with UTF16 surrogates as input.
00db10
+   Copyright (C) 2016 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#include <stdio.h>
00db10
+#include <stdlib.h>
00db10
+#include <errno.h>
00db10
+#include <string.h>
00db10
+#include <inttypes.h>
00db10
+#include <iconv.h>
00db10
+#include <byteswap.h>
00db10
+
00db10
+static int
00db10
+run_conversion (const char *from, const char *to, char *inbuf, size_t inbuflen,
00db10
+		int exp_errno, int line)
00db10
+{
00db10
+  char outbuf[16];
00db10
+  iconv_t cd;
00db10
+  char *inptr;
00db10
+  size_t inlen;
00db10
+  char *outptr;
00db10
+  size_t outlen;
00db10
+  size_t n;
00db10
+  int e;
00db10
+  int fails = 0;
00db10
+
00db10
+  cd = iconv_open (to, from);
00db10
+  if (cd == (iconv_t) -1)
00db10
+    {
00db10
+      printf ("line %d: cannot convert from %s to %s: %m\n", line, from, to);
00db10
+      return 1;
00db10
+    }
00db10
+
00db10
+  inptr = (char *) inbuf;
00db10
+  inlen = inbuflen;
00db10
+  outptr = outbuf;
00db10
+  outlen = sizeof (outbuf);
00db10
+
00db10
+  errno = 0;
00db10
+  n = iconv (cd, &inptr, &inlen, &outptr, &outlen);
00db10
+  e = errno;
00db10
+
00db10
+  if (exp_errno == 0)
00db10
+    {
00db10
+      if (n == (size_t) -1)
00db10
+	{
00db10
+	  puts ("n should be >= 0, but n == -1");
00db10
+	  fails ++;
00db10
+	}
00db10
+
00db10
+      if (e != 0)
00db10
+	{
00db10
+	  printf ("errno should be 0: 'Success', but errno == %d: '%s'\n"
00db10
+		  , e, strerror(e));
00db10
+	  fails ++;
00db10
+	}
00db10
+    }
00db10
+  else
00db10
+    {
00db10
+      if (n != (size_t) -1)
00db10
+	{
00db10
+	  printf ("n should be -1, but n == %zd\n", n);
00db10
+	  fails ++;
00db10
+	}
00db10
+
00db10
+      if (e != exp_errno)
00db10
+	{
00db10
+	  printf ("errno should be %d: '%s', but errno == %d: '%s'\n"
00db10
+		  , exp_errno, strerror (exp_errno), e, strerror (e));
00db10
+	  fails ++;
00db10
+	}
00db10
+    }
00db10
+
00db10
+  iconv_close (cd);
00db10
+
00db10
+  if (fails > 0)
00db10
+    {
00db10
+      printf ("Errors in line %d while converting %s to %s.\n\n"
00db10
+	      , line, from, to);
00db10
+    }
00db10
+
00db10
+  return fails;
00db10
+}
00db10
+
00db10
+static int
00db10
+do_test (void)
00db10
+{
00db10
+  int fails = 0;
00db10
+  char buf[4];
00db10
+
00db10
+  /* This test runs iconv() with UTF character in range of an UTF16 surrogate.
00db10
+     UTF-16 high surrogate is in range 0xD800..0xDBFF and
00db10
+     UTF-16 low surrogate is in range 0xDC00..0xDFFF.
00db10
+     Converting from or to UTF-xx has to report errors in those cases.
00db10
+     In UTF-16, surrogate pairs with a high surrogate in front of a low
00db10
+     surrogate is valid.  */
00db10
+
00db10
+  /* Use RUN_UCS4_UTF32_INPUT to test conversion ...
00db10
+
00db10
+     ... from INTERNAL to UTF-xx[LE|BE]:
00db10
+     Converting from UCS4 to UTF-xx[LE|BE] first converts UCS4 to INTERNAL
00db10
+     without checking for UTF-16 surrogate values
00db10
+     and then converts from INTERNAL to UTF-xx[LE|BE].
00db10
+     The latter conversion has to report an error in those cases.
00db10
+
00db10
+     ... from UTF-32[LE|BE] to INTERNAL:
00db10
+     Converting directly from UTF-32LE to UTF-8|16 is needed,
00db10
+     because e.g. s390x has iconv-modules which converts directly.  */
00db10
+#define RUN_UCS4_UTF32_INPUT(b0, b1, b2, b3, err, line)			\
00db10
+  buf[0] = b0;								\
00db10
+  buf[1] = b1;								\
00db10
+  buf[2] = b2;								\
00db10
+  buf[3] = b3;								\
00db10
+  fails += run_conversion ("UCS4", "UTF-8", buf, 4, err, line);		\
00db10
+  fails += run_conversion ("UCS4", "UTF-16LE", buf, 4, err, line);	\
00db10
+  fails += run_conversion ("UCS4", "UTF-16BE", buf, 4, err, line);	\
00db10
+  fails += run_conversion ("UCS4", "UTF-32LE", buf, 4, err, line);	\
00db10
+  fails += run_conversion ("UCS4", "UTF-32BE", buf, 4, err, line);	\
00db10
+  fails += run_conversion ("UTF-32BE", "WCHAR_T", buf, 4, err, line);	\
00db10
+  fails += run_conversion ("UTF-32BE", "UTF-8", buf, 4, err, line);	\
00db10
+  fails += run_conversion ("UTF-32BE", "UTF-16LE", buf, 4, err, line);	\
00db10
+  fails += run_conversion ("UTF-32BE", "UTF-16BE", buf, 4, err, line);	\
00db10
+  buf[0] = b3;								\
00db10
+  buf[1] = b2;								\
00db10
+  buf[2] = b1;								\
00db10
+  buf[3] = b0;								\
00db10
+  fails += run_conversion ("UTF-32LE", "WCHAR_T", buf, 4, err, line);	\
00db10
+  fails += run_conversion ("UTF-32LE", "UTF-8", buf, 4, err, line);	\
00db10
+  fails += run_conversion ("UTF-32LE", "UTF-16LE", buf, 4, err, line);	\
00db10
+  fails += run_conversion ("UTF-32LE", "UTF-16BE", buf, 4, err, line);
00db10
+
00db10
+  /* Use UCS4/UTF32 input of 0xD7FF.  */
00db10
+  RUN_UCS4_UTF32_INPUT (0x0, 0x0, 0xD7, 0xFF, 0, __LINE__);
00db10
+
00db10
+  /* Use UCS4/UTF32 input of 0xD800.  */
00db10
+  RUN_UCS4_UTF32_INPUT (0x0, 0x0, 0xD8, 0x00, EILSEQ, __LINE__);
00db10
+
00db10
+  /* Use UCS4/UTF32 input of 0xDBFF.  */
00db10
+  RUN_UCS4_UTF32_INPUT (0x0, 0x0, 0xDB, 0xFF, EILSEQ, __LINE__);
00db10
+
00db10
+  /* Use UCS4/UTF32 input of 0xDC00.  */
00db10
+  RUN_UCS4_UTF32_INPUT (0x0, 0x0, 0xDC, 0x00, EILSEQ, __LINE__);
00db10
+
00db10
+  /* Use UCS4/UTF32 input of 0xDFFF.  */
00db10
+  RUN_UCS4_UTF32_INPUT (0x0, 0x0, 0xDF, 0xFF, EILSEQ, __LINE__);
00db10
+
00db10
+  /* Use UCS4/UTF32 input of 0xE000.  */
00db10
+  RUN_UCS4_UTF32_INPUT (0x0, 0x0, 0xE0, 0x00, 0, __LINE__);
00db10
+
00db10
+
00db10
+  /* Use RUN_UTF16_INPUT to test conversion from UTF16[LE|BE] to INTERNAL.
00db10
+     Converting directly from UTF-16 to UTF-8|32 is needed,
00db10
+     because e.g. s390x has iconv-modules which converts directly.
00db10
+     Use len == 2 or 4 to specify one or two UTF-16 characters.  */
00db10
+#define RUN_UTF16_INPUT(b0, b1, b2, b3, len, err, line)			\
00db10
+  buf[0] = b0;								\
00db10
+  buf[1] = b1;								\
00db10
+  buf[2] = b2;								\
00db10
+  buf[3] = b3;								\
00db10
+  fails += run_conversion ("UTF-16BE", "WCHAR_T", buf, len, err, line);	\
00db10
+  fails += run_conversion ("UTF-16BE", "UTF-8", buf, len, err, line);	\
00db10
+  fails += run_conversion ("UTF-16BE", "UTF-32LE", buf, len, err, line); \
00db10
+  fails += run_conversion ("UTF-16BE", "UTF-32BE", buf, len, err, line); \
00db10
+  buf[0] = b1;								\
00db10
+  buf[1] = b0;								\
00db10
+  buf[2] = b3;								\
00db10
+  buf[3] = b2;								\
00db10
+  fails += run_conversion ("UTF-16LE", "WCHAR_T", buf, len, err, line);	\
00db10
+  fails += run_conversion ("UTF-16LE", "UTF-8", buf, len, err, line);	\
00db10
+  fails += run_conversion ("UTF-16LE", "UTF-32LE", buf, len, err, line); \
00db10
+  fails += run_conversion ("UTF-16LE", "UTF-32BE", buf, len, err, line);
00db10
+
00db10
+  /* Use UTF16 input of 0xD7FF.  */
00db10
+  RUN_UTF16_INPUT (0xD7, 0xFF, 0xD7, 0xFF, 4, 0, __LINE__);
00db10
+
00db10
+  /* Use [single] UTF16 high surrogate 0xD800 [with a valid character behind].
00db10
+     And check an UTF16 surrogate pair [without valid low surrogate].  */
00db10
+  RUN_UTF16_INPUT (0xD8, 0x0, 0x0, 0x0, 2, EINVAL, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xD8, 0x0, 0xD7, 0xFF, 4, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xD8, 0x0, 0xD8, 0x0, 4, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xD8, 0x0, 0xE0, 0x0, 4, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xD8, 0x0, 0xDC, 0x0, 4, 0, __LINE__);
00db10
+
00db10
+  /* Use [single] UTF16 high surrogate 0xDBFF [with a valid character behind].
00db10
+     And check an UTF16 surrogate pair [without valid low surrogate].  */
00db10
+  RUN_UTF16_INPUT (0xDB, 0xFF, 0x0, 0x0, 2, EINVAL, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xDB, 0xFF, 0xD7, 0xFF, 4, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xDB, 0xFF, 0xDB, 0xFF, 4, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xDB, 0xFF, 0xE0, 0x0, 4, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xDB, 0xFF, 0xDF, 0xFF, 4, 0, __LINE__);
00db10
+
00db10
+  /* Use single UTF16 low surrogate 0xDC00 [with a valid character behind].
00db10
+     And check an UTF16 surrogate pair [without valid high surrogate].   */
00db10
+  RUN_UTF16_INPUT (0xDC, 0x0, 0x0, 0x0, 2, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xDC, 0x0, 0xD7, 0xFF, 4, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xD8, 0x0, 0xDC, 0x0, 4, 0, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xD7, 0xFF, 0xDC, 0x0, 4, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xDC, 0x0, 0xDC, 0x0, 4, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xE0, 0x0, 0xDC, 0x0, 4, EILSEQ, __LINE__);
00db10
+
00db10
+  /* Use single UTF16 low surrogate 0xDFFF [with a valid character behind].
00db10
+     And check an UTF16 surrogate pair [without valid high surrogate].   */
00db10
+  RUN_UTF16_INPUT (0xDF, 0xFF, 0x0, 0x0, 2, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xDF, 0xFF, 0xD7, 0xFF, 4, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xDB, 0xFF, 0xDF, 0xFF, 4, 0, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xD7, 0xFF, 0xDF, 0xFF, 4, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xDF, 0xFF, 0xDF, 0xFF, 4, EILSEQ, __LINE__);
00db10
+  RUN_UTF16_INPUT (0xE0, 0x0, 0xDF, 0xFF, 4, EILSEQ, __LINE__);
00db10
+
00db10
+  /* Use UCS4/UTF32 input of 0xE000.  */
00db10
+  RUN_UTF16_INPUT (0xE0, 0x0, 0xE0, 0x0, 4, 0, __LINE__);
00db10
+
00db10
+
00db10
+  /* Use RUN_UTF8_3BYTE_INPUT to test conversion from UTF-8 to INTERNAL.
00db10
+     Converting directly from UTF-8 to UTF-16|32 is needed,
00db10
+     because e.g. s390x has iconv-modules which converts directly.  */
00db10
+#define RUN_UTF8_3BYTE_INPUT(b0, b1, b2, err, line)			\
00db10
+  buf[0] = b0;								\
00db10
+  buf[1] = b1;								\
00db10
+  buf[2] = b2;								\
00db10
+  fails += run_conversion ("UTF-8", "WCHAR_T", buf, 3, err, line);	\
00db10
+  fails += run_conversion ("UTF-8", "UTF-16LE", buf, 3, err, line);	\
00db10
+  fails += run_conversion ("UTF-8", "UTF-16BE", buf, 3, err, line);	\
00db10
+  fails += run_conversion ("UTF-8", "UTF-32LE", buf, 3, err, line);	\
00db10
+  fails += run_conversion ("UTF-8", "UTF-32BE", buf, 3, err, line);
00db10
+
00db10
+  /* Use UTF-8 input of 0xD7FF.  */
00db10
+  RUN_UTF8_3BYTE_INPUT (0xED, 0x9F, 0xBF, 0, __LINE__);
00db10
+
00db10
+  /* Use UTF-8 input of 0xD800.  */
00db10
+  RUN_UTF8_3BYTE_INPUT (0xED, 0xA0, 0x80, EILSEQ, __LINE__);
00db10
+
00db10
+  /* Use UTF-8 input of 0xDBFF.  */
00db10
+  RUN_UTF8_3BYTE_INPUT (0xED, 0xAF, 0xBF, EILSEQ, __LINE__);
00db10
+
00db10
+  /* Use UTF-8 input of 0xDC00.  */
00db10
+  RUN_UTF8_3BYTE_INPUT (0xED, 0xB0, 0x80, EILSEQ, __LINE__);
00db10
+
00db10
+  /* Use UTF-8 input of 0xDFFF.  */
00db10
+  RUN_UTF8_3BYTE_INPUT (0xED, 0xBF, 0xBF, EILSEQ, __LINE__);
00db10
+
00db10
+  /* Use UTF-8 input of 0xF000.  */
00db10
+  RUN_UTF8_3BYTE_INPUT (0xEF, 0x80, 0x80, 0, __LINE__);
00db10
+
00db10
+  return fails > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
00db10
+}
00db10
+
00db10
+#define TEST_FUNCTION do_test ()
00db10
+#include "../test-skeleton.c"
00db10
diff --git a/iconvdata/utf-16.c b/iconvdata/utf-16.c
00db10
index b4ddfeb..e833d3c 100644
00db10
--- a/iconvdata/utf-16.c
00db10
+++ b/iconvdata/utf-16.c
00db10
@@ -294,6 +294,12 @@ gconv_end (struct __gconv_step *data)
00db10
 	  {								      \
00db10
 	    uint16_t u2;						      \
00db10
 									      \
00db10
+	    if (__glibc_unlikely (u1 >= 0xdc00))			      \
00db10
+	      {								      \
00db10
+		/* This is no valid first word for a surrogate.  */	      \
00db10
+		STANDARD_FROM_LOOP_ERR_HANDLER (2);			      \
00db10
+	      }								      \
00db10
+									      \
00db10
 	    /* It's a surrogate character.  At least the first word says      \
00db10
 	       it is.  */						      \
00db10
 	    if (__builtin_expect (inptr + 4 > inend, 0))		      \
00db10
@@ -328,6 +334,12 @@ gconv_end (struct __gconv_step *data)
00db10
 	  }								      \
00db10
 	else								      \
00db10
 	  {								      \
00db10
+	    if (__glibc_unlikely (u1 >= 0xdc00))			      \
00db10
+	      {								      \
00db10
+		/* This is no valid first word for a surrogate.  */	      \
00db10
+		STANDARD_FROM_LOOP_ERR_HANDLER (2);			      \
00db10
+	      }								      \
00db10
+									      \
00db10
 	    /* It's a surrogate character.  At least the first word says      \
00db10
 	       it is.  */						      \
00db10
 	    if (__builtin_expect (inptr + 4 > inend, 0))		      \
00db10
diff --git a/iconvdata/utf-32.c b/iconvdata/utf-32.c
00db10
index e0c4b19..1173d6f 100644
00db10
--- a/iconvdata/utf-32.c
00db10
+++ b/iconvdata/utf-32.c
00db10
@@ -238,7 +238,8 @@ gconv_end (struct __gconv_step *data)
00db10
     if (swap)								      \
00db10
       u1 = bswap_32 (u1);						      \
00db10
 									      \
00db10
-    if (__builtin_expect (u1 >= 0x110000, 0))				      \
00db10
+    if (__builtin_expect (u1 >= 0x110000				      \
00db10
+			  || (u1 >= 0xd800 && u1 < 0xe000), 0))		      \
00db10
       {									      \
00db10
 	/* This is illegal.  */						      \
00db10
 	STANDARD_FROM_LOOP_ERR_HANDLER (4);				      \
00db10
-- 
00db10
1.8.3.1
00db10