]> git.ipfire.org Git - people/ms/gcc.git/commit
libstdc++: Adjust overflow prevention to operator>>
authorJonathan Wakely <jwakely@redhat.com>
Thu, 6 Aug 2020 15:16:33 +0000 (16:16 +0100)
committerGiuliano Belinassi <giuliano.belinassi@usp.br>
Mon, 17 Aug 2020 18:07:45 +0000 (15:07 -0300)
commitda3d64a7cde5326c90319eb686f322213d32165b
treeebe0db35b08ac537440c5589686cc423e5591fef
parent43f5831006277036b07a9c4637d092e0c3d32ceb
libstdc++: Adjust overflow prevention to operator>>

This adjusts the overflow prevention added to operator>> so that we can
distinguish "unknown size" from "zero size", and avoid writing anything
at all in to zero sized buffers.

This also removes the incorrect comment saying extraction stops at a
null byte.

libstdc++-v3/ChangeLog:

* include/std/istream (operator>>(istream&, char*)): Add
attributes to get warnings for pointers that are null or known
to point to the end of a buffer. Request upper bound from
__builtin_object_size check and handle zero-sized buffer case.
(operator>>(istream&, signed char))
(operator>>(istream&, unsigned char*)): Add attributes.
* testsuite/27_io/basic_istream/extractors_character/char/overflow.cc:
Check extracting into the middle of a buffer.
* testsuite/27_io/basic_istream/extractors_character/wchar_t/overflow.cc: New test.
libstdc++-v3/include/std/istream
libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/overflow.cc
libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/overflow.cc [new file with mode: 0644]