Skip to content

Commit

Permalink
[libc++] Fix segmentation fault in __do_put_integral
Browse files Browse the repository at this point in the history
6 chars are not sufficient to represent all formats for 64 bit integers.

This was accidentally introduced in commit b889cbf (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
  • Loading branch information
MarcoFalke committed Nov 10, 2021
1 parent 51ae78a commit faa019c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libcxx/include/locale
Expand Up @@ -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.
Expand Down

0 comments on commit faa019c

Please sign in to comment.