This is an archive of the discontinued LLVM Phabricator instance.

Ensure showbase does not overflow do_put buffers
ClosedPublic

Authored by dim on Apr 29 2017, 7:17 AM.

Details

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.

Event Timeline

dim created this revision.Apr 29 2017, 7:17 AM
dim added a comment.Apr 29 2017, 7:20 AM

Note: I copied some of the test case from rL227097, which had a similar case of a too short buffer.

dim updated this revision to Diff 97198.Apr 29 2017, 2:06 PM

Simplify test case a bit.

EricWF accepted this revision.May 6 2017, 2:02 PM
This revision is now accepted and ready to land.May 6 2017, 2:02 PM
dim closed this revision.May 6 2017, 2:11 PM