aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c-cppbuiltin.c
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2020-07-20 20:06:46 +0100
committerJonathan Wakely <jwakely@redhat.com>2020-07-20 20:06:46 +0100
commit4d1c5b4957db2cb07f1053b7b87767275497d52e (patch)
tree177ba6f54bbfb42d2f020e0295ebf30ae0604107 /gcc/c-family/c-cppbuiltin.c
parent138b1d4f58af17986e856e665ffbd561c2c8740e (diff)
downloadgcc-4d1c5b4957db2cb07f1053b7b87767275497d52e.zip
gcc-4d1c5b4957db2cb07f1053b7b87767275497d52e.tar.gz
gcc-4d1c5b4957db2cb07f1053b7b87767275497d52e.tar.bz2
libstdc++: Avoid overflow in istream::get(streambuf&) [LWG 3464]
Similar to the recent changes to basic_istream::ignore, this change ensures that _M_gcount doesn't overflow when extracting characters and inserting them into another streambuf. The solution used here is to use unsigned long long for the count. We assume that the number of characters extracted won't exceed the maximum value for that type, but even if it does we avoid any undefined behaviour. libstdc++-v3/ChangeLog: * include/bits/istream.tcc (basic_istream::get(__streambuf_type&, char_type): Use unsigned long long for counter and check if it would overflow _M_gcount. * testsuite/27_io/basic_istream/get/char/lwg3464.cc: New test. * testsuite/27_io/basic_istream/get/wchar_t/lwg3464.cc: New test.
Diffstat (limited to 'gcc/c-family/c-cppbuiltin.c')
0 files changed, 0 insertions, 0 deletions