[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-27 Thread andysem at mail dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #16 from andysem at mail dot ru --- Thanks for the fix. And for the explanation. Yes, backport would be nice.

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-27 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #15 from Jonathan Wakely --- Fixed on trunk, but this code has been present since 2003 so I want to backport it to all active branches.

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-27 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #14 from GCC Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:498f9aefbf36b0e3f119d634c41d86699ce6fed2 commit r15-5718-g498f9aefbf36b0e3f119d634c41d86699ce6fed2 Author: Jonathan Wakely Date

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-26 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #13 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #12) > Overflow is possible though. If you call it with max = (-1ull / 4 + 2) then > the alloca length will be 4. If (from_end - from) requires more than 4 wide

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-26 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #12 from Jonathan Wakely --- Overflow is possible though. If you call it with max = (-1ull / 4 + 2) then the alloca length will be 4. If (from_end - from) requires more than 4 wide characters, we'll overflow the alloca buffer.

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-26 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 Jonathan Wakely changed: What|Removed |Added Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-26 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #10 from Jonathan Wakely --- (In reply to andysem from comment #0) > The problem appears to be that std::codecvt< wchar_t, char, std::mbstate_t > >::do_length() accesses characters outside the [s, s + max_size) range, I'm pretty sur

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-20 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 Sam James changed: What|Removed |Added CC||sjames at gcc dot gnu.org --- Comment #9 fr

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-19 Thread andysem at mail dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #7 from andysem at mail dot ru --- Reproduces for me: $ g++ -g2 -O0 -o codecvt_length_bug codecvt_length_bug.cpp $ ./codecvt_length_bug *** buffer overflow detected ***: terminated Aborted (core dumped) $ g++ -v Using built-in specs

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-19 Thread andysem at mail dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #8 from andysem at mail dot ru --- I think, sanitizers won't detect it unless you build libstdc++ with them enabled. I would expect valgrind to detect it though. I think, Ubuntu builds libstdc++ with _FORTIFY_SOURCE enabled, which is

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-19 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #6 from Jonathan Wakely --- I can't reproduce a crash, or any runtime error from valgrind, ubsan, asan, ...

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-19 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #5 from Jonathan Wakely --- You can click on the "Keywords" link to see the meanings.

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-19 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #4 from Sam James --- It means "GCC (in some form) generates incorrect code for a valid testcase".

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2024-11-19 Thread andysem at mail dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #3 from andysem at mail dot ru --- I'm not sure about the meaning of the wrong-code keyword, but just to clear, I do not consider the code sample in the bug report to be wrong (i.e. incorrect usage of the standard library). If it is w

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2022-06-07 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 Jonathan Wakely changed: What|Removed |Added Ever confirmed|0 |1 Last reconfirmed|

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2022-06-05 Thread andysem at mail dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #2 from andysem at mail dot ru --- > outside the [s, s + max_size) range This should be [from, from_to) range. Sorry, posted a little too soon.

[Bug libstdc++/105857] codecvt::do_length causes unexpected buffer overflow

2022-06-05 Thread andysem at mail dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857 --- Comment #1 from andysem at mail dot ru --- Created attachment 53089 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53089&action=edit Test case to reproduce the problem.