From owner-svn-src-head@FreeBSD.ORG Tue Apr 29 15:25:58 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id F24368E3; Tue, 29 Apr 2014 15:25:57 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DEE601342; Tue, 29 Apr 2014 15:25:57 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3TFPvS0097590; Tue, 29 Apr 2014 15:25:57 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3TFPvmt097589; Tue, 29 Apr 2014 15:25:57 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201404291525.s3TFPvmt097589@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Tue, 29 Apr 2014 15:25:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r265095 - head/lib/libc/locale X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Apr 2014 15:25:58 -0000 Author: pfg Date: Tue Apr 29 15:25:57 2014 New Revision: 265095 URL: http://svnweb.freebsd.org/changeset/base/265095 Log: citrus: Avoid invalid code points. From the OpenBSD log: The UTF-8 decoder should not accept byte sequences which decode to unicode code positions U+D800 to U+DFFF (UTF-16 surrogates), U+FFFE, and U+FFFF. http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 http://unicode.org/faq/utf_bom.html#utf8-4 Reported by: Stefan Sperling Obtained from: OpenBSD MFC after: 5 days Modified: head/lib/libc/locale/utf8.c Modified: head/lib/libc/locale/utf8.c ============================================================================== --- head/lib/libc/locale/utf8.c Tue Apr 29 15:12:23 2014 (r265094) +++ head/lib/libc/locale/utf8.c Tue Apr 29 15:25:57 2014 (r265095) @@ -203,6 +203,14 @@ _UTF8_mbrtowc(wchar_t * __restrict pwc, errno = EILSEQ; return ((size_t)-1); } + if ((wch >= 0xd800 && wch <= 0xdfff) || + wch == 0xfffe || wch == 0xffff) { + /* + * Malformed input; invalid code points. + */ + errno = EILSEQ; + return ((size_t)-1); + } if (pwc != NULL) *pwc = wch; us->want = 0;