[libc++] Fix segmentation fault in __do_put_integral

6 chars are not sufficient to represent all formats for 64 bit integers.

This was accidentally introduced in commit b889cbf366 (https://reviews.llvm.org/D112830).

This causes failures in downstream projects, for example:

* https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40817
* https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40841

Differential Revision: https://reviews.llvm.org/D113600
This commit is contained in:
MarcoFalke 2021-11-10 20:34:31 +01:00
parent 51ae78a6d6
commit faa019c0e3
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548
1 changed files with 1 additions and 1 deletions

View File

@ -1476,7 +1476,7 @@ num_put<_CharT, _OutputIterator>::__do_put_integral(iter_type __s, ios_base& __i
char const* __len) const
{
// Stage 1 - Get number in narrow char
char __fmt[6] = {'%', 0};
char __fmt[8] = {'%', 0};
this->__format_int(__fmt+1, __len, is_signed<_Integral>::value, __iob.flags());
// Worst case is octal, with showbase enabled. Note that octal is always
// printed as an unsigned value.