diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2023-06-26 14:46:46 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2023-06-26 17:43:22 +0100 |
commit | 3bb9f9329c378934541ae4cff9977b7487e97cf0 (patch) | |
tree | 5730bf5e1eee92a5365cd44b3bda9379369b561c /libgcc/enable-execute-stack-empty.c | |
parent | 6eafdfc73c21d7a5e59e18c9dee275af5bf6d979 (diff) | |
download | gcc-3bb9f9329c378934541ae4cff9977b7487e97cf0.zip gcc-3bb9f9329c378934541ae4cff9977b7487e97cf0.tar.gz gcc-3bb9f9329c378934541ae4cff9977b7487e97cf0.tar.bz2 |
libstdc++: Fix std::format for pointers [PR110239]
The formatter for pointers was casting to uint64_t which sign extends a
32-bit pointer and produces a value that won't fit in the provided
buffer. Cast to uintptr_t instead.
There was also a bug in the __parse_integer helper when converting a
wide string to a narrow string in order to use std::from_chars on it.
The function would always try to read 32 characters, even if the format
string was shorter than that. Fix that bug, and remove the constexpr
implementation of __parse_integer by just using __from_chars_alnum
instead of from_chars, because that's usable in constexpr even in
C++20.
libstdc++-v3/ChangeLog:
PR libstdc++/110239
* include/std/format (__format::__parse_integer): Fix buffer
overflow for wide chars.
(formatter<const void*, C>::format): Cast to uintptr_t instead
of uint64_t.
* testsuite/std/format/string.cc: Test too-large widths.
Diffstat (limited to 'libgcc/enable-execute-stack-empty.c')
0 files changed, 0 insertions, 0 deletions