summaryrefslogtreecommitdiffstats
path: root/contrib/libc++/include
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2017-05-09 16:58:08 +0000
committerdim <dim@FreeBSD.org>2017-05-09 16:58:08 +0000
commit1ed8c83ef5d3e562c3451bdf86d9ef2e8119a543 (patch)
tree5022a94d1cf7bb2e554d02814e374ce8de9e2578 /contrib/libc++/include
parentcd8758a009b5932c800b7cbfd44fdf25e3ffe6ff (diff)
downloadFreeBSD-src-1ed8c83ef5d3e562c3451bdf86d9ef2e8119a543.zip
FreeBSD-src-1ed8c83ef5d3e562c3451bdf86d9ef2e8119a543.tar.gz
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
Diffstat (limited to 'contrib/libc++/include')
-rw-r--r--contrib/libc++/include/locale8
1 files changed, 6 insertions, 2 deletions
diff --git a/contrib/libc++/include/locale b/contrib/libc++/include/locale
index 0d01002..b2904b03 100644
--- a/contrib/libc++/include/locale
+++ b/contrib/libc++/include/locale
@@ -1555,7 +1555,8 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
this->__format_int(__fmt+1, __len, true, __iob.flags());
const unsigned __nbuf = (numeric_limits<long>::digits / 3)
+ ((numeric_limits<long>::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(iter_type __s, ios_base& __iob,
this->__format_int(__fmt+1, __len, true, __iob.flags());
const unsigned __nbuf = (numeric_limits<long long>::digits / 3)
+ ((numeric_limits<long long>::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(iter_type __s, ios_base& __iob,
this->__format_int(__fmt+1, __len, false, __iob.flags());
const unsigned __nbuf = (numeric_limits<unsigned long>::digits / 3)
+ ((numeric_limits<unsigned long>::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(iter_type __s, ios_base& __iob,
this->__format_int(__fmt+1, __len, false, __iob.flags());
const unsigned __nbuf = (numeric_limits<unsigned long long>::digits / 3)
+ ((numeric_limits<unsigned long long>::digits % 3) != 0)
+ + ((__iob.flags() & ios_base::showbase) != 0)
+ 1;
char __nar[__nbuf];
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
OpenPOWER on IntegriCloud