svn commit: r286518 - projects/collation/lib/libc/locale

Baptiste Daroussin bapt at FreeBSD.org
Sun Aug 9 10:36:26 UTC 2015


Author: bapt
Date: Sun Aug  9 10:36:25 2015
New Revision: 286518
URL: https://svnweb.freebsd.org/changeset/base/286518

Log:
  Readd checking utf16 surrogates that are invalid in utf8

Modified:
  projects/collation/lib/libc/locale/utf8.c

Modified: projects/collation/lib/libc/locale/utf8.c
==============================================================================
--- projects/collation/lib/libc/locale/utf8.c	Sun Aug  9 10:24:24 2015	(r286517)
+++ projects/collation/lib/libc/locale/utf8.c	Sun Aug  9 10:36:25 2015	(r286518)
@@ -193,6 +193,13 @@ _UTF8_mbrtowc(wchar_t * __restrict pwc, 
 		errno = EILSEQ;
 		return ((size_t)-1);
 	}
+	if (wch >= 0xd800 && wch <= 0xdfff) {
+		/*
+		 * Malformed input; invalid code points.
+		 */
+		errno = EILSEQ;
+		return ((size_t)-1);
+	}
 	if (pwc != NULL)
 		*pwc = wch;
 	us->want = 0;


More information about the svn-src-projects mailing list