https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92853
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- Author: redi Date: Mon Dec 9 09:58:56 2019 New Revision: 279110 URL: https://gcc.gnu.org/viewcvs?rev=279110&root=gcc&view=rev Log: libstdc++: fix buffer overflow in path::operator+= (PR92853) When concatenating a path ending in a root-directory onto another path, we added an empty filename to the end of the path twice, but only reserved space for one. That meant the second write went past the end of the allocated buffer. PR libstdc++/92853 * src/c++17/fs_path.cc (filesystem::path::operator+=(const path&)): Do not process a trailing directory separator twice. * testsuite/27_io/filesystem/path/concat/92853.cc: New test. * testsuite/27_io/filesystem/path/concat/path.cc: Test more cases. Added: trunk/libstdc++-v3/testsuite/27_io/filesystem/path/concat/92853.cc - copied, changed from r279109, trunk/libstdc++-v3/testsuite/27_io/filesystem/path/concat/path.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/src/c++17/fs_path.cc trunk/libstdc++-v3/testsuite/27_io/filesystem/path/concat/path.cc