From owner-svn-src-stable@freebsd.org Thu Mar 31 01:36:52 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 38863AE1D8B; Thu, 31 Mar 2016 01:36:52 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 EF6C61285; Thu, 31 Mar 2016 01:36:51 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u2V1apw2081628; Thu, 31 Mar 2016 01:36:51 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u2V1apg6081627; Thu, 31 Mar 2016 01:36:51 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201603310136.u2V1apg6081627@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Thu, 31 Mar 2016 01:36:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r297440 - stable/10/lib/libc/locale X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2016 01:36:52 -0000 Author: pfg Date: Thu Mar 31 01:36:50 2016 New Revision: 297440 URL: https://svnweb.freebsd.org/changeset/base/297440 Log: MFC r296278: mbtowc(3): set errno to EILSEQ if an incomplete character is passed. According to POSIX, The mbtowc() function shall fail if: [EILSEQ] An invalid character sequence is detected. Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D5496 Obtained from: OpenBSD (Ingo Schwarze) Modified: stable/10/lib/libc/locale/mbtowc.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/locale/mbtowc.c ============================================================================== --- stable/10/lib/libc/locale/mbtowc.c Thu Mar 31 00:53:23 2016 (r297439) +++ stable/10/lib/libc/locale/mbtowc.c Thu Mar 31 01:36:50 2016 (r297440) @@ -32,6 +32,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include "mblocal.h" @@ -49,9 +50,15 @@ mbtowc_l(wchar_t * __restrict pwc, const return (0); } rval = XLOCALE_CTYPE(locale)->__mbrtowc(pwc, s, n, &locale->mbtowc); - if (rval == (size_t)-1 || rval == (size_t)-2) + switch (rval) { + case (size_t)-2: + errno = EILSEQ; + /* FALLTHROUGH */ + case (size_t)-1: return (-1); - return ((int)rval); + default: + return ((int)rval); + } } int mbtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n)