From owner-svn-src-stable@freebsd.org Tue May 9 16:58:10 2017 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 31AB0D653DB; Tue, 9 May 2017 16:58:10 +0000 (UTC) (envelope-from dim@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 0C3431796; Tue, 9 May 2017 16:58:09 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v49Gw9bF045220; Tue, 9 May 2017 16:58:09 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v49Gw99B045219; Tue, 9 May 2017 16:58:09 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201705091658.v49Gw99B045219@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Tue, 9 May 2017 16:58:09 +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: r318031 - stable/10/contrib/libc++/include 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.23 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: Tue, 09 May 2017 16:58:10 -0000 Author: dim Date: Tue May 9 16:58:08 2017 New Revision: 318031 URL: https://svnweb.freebsd.org/changeset/base/318031 Log: MFC r317888 and two upstream prerequisites: Pull in r227097 from upstream libc++ trunk (by Marshall Clow): Fix PR21428. Buffer was one byte too small in octal formatting case. Add test Pull in r268009 from upstream libc++ trunk (by Eric Fiselier): Fix PR21428 for long. Buffer was one byte too small in octal formatting case. Rename previously added test Pull in r302362 from upstream libc++ trunk (by me): Ensure showbase does not overflow do_put buffers Summary: In https://bugs.freebsd.org/207918, Daniel McRobb describes how using std::showbase with ostreams can cause truncation of unsigned long long when output format is octal. In fact, this can even happen with unsigned int and unsigned long. To ensure this does not happen, add one additional character to the do_put buffers if std::showbase is on. Also add a test case. Reviewers: EricWF, mclow.lists Reviewed By: EricWF Subscribers: cfe-commits, emaste Differential Revision: https://reviews.llvm.org/D32670 PR: 207918 Modified: stable/10/contrib/libc++/include/locale Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/libc++/include/locale ============================================================================== --- stable/10/contrib/libc++/include/locale Tue May 9 16:29:06 2017 (r318030) +++ stable/10/contrib/libc++/include/locale Tue May 9 16:58:08 2017 (r318031) @@ -1555,7 +1555,8 @@ num_put<_CharT, _OutputIterator>::do_put this->__format_int(__fmt+1, __len, true, __iob.flags()); const unsigned __nbuf = (numeric_limits::digits / 3) + ((numeric_limits::digits % 3) != 0) - + 1; + + ((__iob.flags() & ios_base::showbase) != 0) + + 2; char __nar[__nbuf]; #ifdef _LIBCPP_LOCALE__L_EXTENSIONS int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); @@ -1585,7 +1586,8 @@ num_put<_CharT, _OutputIterator>::do_put this->__format_int(__fmt+1, __len, true, __iob.flags()); const unsigned __nbuf = (numeric_limits::digits / 3) + ((numeric_limits::digits % 3) != 0) - + 1; + + ((__iob.flags() & ios_base::showbase) != 0) + + 2; char __nar[__nbuf]; #ifdef _LIBCPP_LOCALE__L_EXTENSIONS int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); @@ -1615,6 +1617,7 @@ num_put<_CharT, _OutputIterator>::do_put this->__format_int(__fmt+1, __len, false, __iob.flags()); const unsigned __nbuf = (numeric_limits::digits / 3) + ((numeric_limits::digits % 3) != 0) + + ((__iob.flags() & ios_base::showbase) != 0) + 1; char __nar[__nbuf]; #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -1645,6 +1648,7 @@ num_put<_CharT, _OutputIterator>::do_put this->__format_int(__fmt+1, __len, false, __iob.flags()); const unsigned __nbuf = (numeric_limits::digits / 3) + ((numeric_limits::digits % 3) != 0) + + ((__iob.flags() & ios_base::showbase) != 0) + 1; char __nar[__nbuf]; #ifdef _LIBCPP_LOCALE__L_EXTENSIONS