Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Reimar Döffinger via cfe-commits
On 21.11.2017, at 03:54, Volodymyr Sapsai wrote: > >> If (exceptions()) != 0 then the exception is rethrown. > And looks like libstdc++ rethrows exception even if badbit is not set. Thanks for looking all that up, I was in a hurry. > If you feel comfortable, I can finish

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Reimar Döffinger via cfe-commits
On 20 November 2017 22:19:04 CET, Volodymyr Sapsai wrote: >On Nov 20, 2017, at 11:32, Reimar Döffinger >wrote: >> >> On Mon, Nov 20, 2017 at 11:02:13AM -0800, Volodymyr Sapsai wrote: catch (...) { +if (__n > 0) +

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Reimar Döffinger via cfe-commits
On Mon, Nov 20, 2017 at 11:02:13AM -0800, Volodymyr Sapsai wrote: > > catch (...) > > { > > +if (__n > 0) > > +*__s = char_type(); > > this->__set_badbit_and_consider_rethrow(); > > } > > or maybe something else? That one (note that the

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-19 Thread Reimar Döffinger via cfe-commits
On Wed, Nov 15, 2017 at 11:35:56AM -0800, Volodymyr Sapsai wrote: > On Nov 12, 2017, at 12:37, Reimar Döffinger wrote: > libc++ can be built with exceptions enabled or disabled (see > LIBCXX_ENABLE_EXCEPTIONS >

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-09 Thread Reimar Döffinger via cfe-commits
onditions (specified formally or in natural language) for at least parts easy to specify in such a way to allow at least partial formal verification or proof of correctness isn't exactly state-of-the-art either. Kind regards, Reimar Döffinger > > On Oct 4, 2017, at 12:07, Reimar Döffinger via cfe

[PATCH] Ensure std::getline always 0-terminates string.

2017-10-04 Thread Reimar Döffinger via cfe-commits
If the sentinel failed (e.g. due to having reached EOF before) or an exception was caught it failed to do that. The C++14 standard says: "In any case, if n is greater than zero, it then stores a null character (using charT()) into the next successive location of the array." Other implementations

[PATCH] [libcxx] Ensure std::getline always 0-terminates string.

2017-09-08 Thread Reimar Döffinger via cfe-commits
If the sentinel failed (e.g. due to having reached EOF before) or an exception was caught it failed to do that. While it seems (unfortunately!) not required by the specification, libstdc++ does 0-terminate and not doing so risks creating security issues in applications. --- include/istream | 6