[PATCH] libstdc++: fix buffer overflow in path::operator+= (PR92853)

Jonathan Wakely jwakely@redhat.com
Mon Dec 9 10:00:00 GMT 2019


On 09/12/19 09:55 +0000, Jonathan Wakely wrote:
>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.

This adds similar improvements to the test for operator+= for strings,
rather than operator+=(const path&).

Tested x86_64-linux, committed to trunk. I'll backport this to
gcc-9-branch too.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 1119 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20191209/3cbb2cfc/attachment.bin>


More information about the Libstdc++ mailing list