fuzz: refactor memcpy to std::ranges::copy to work around ubsan warn
Using std::ranges::copy from the C++ standard library has a few benefits
here:
* It has the additional benefit of being a bit more type safe and
document the byte cast explicitly.
* The compiler will likely optimize it to the same asm, but performance
doesn't really matter here anyway.
* It works around an UB-Sanitizer bug, when the source range is empty.
Fixes https://github.com/bitcoin/bitcoin/issues/33643
fa4b52bd16
DrahtBot added the label
Tests
on Oct 30, 2025
DrahtBot
commented at 10:10 am on October 30, 2025:
contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
purpleKarrot
commented at 1:30 pm on October 30, 2025:
contributor
It works around an UB-Sanitizer bug, when the source range is empty.
I guess what you want to express is:
It has defined semantics for empty source ranges.
Passing a zero length to memcpy is UB per the language standard. This is not an “UB-Sanitizer bug”.
fanquake added the label
Fuzzing
on Oct 30, 2025
maflcko
commented at 2:18 pm on October 30, 2025:
member
Yeah, I guess it is too early to call this a bug, but the language standard has been changed, see #33644 (comment).
I’ve used your wording for now.
marcofleon
commented at 3:01 pm on October 30, 2025:
contributor
tACKfa4b52bd16189d40761c5976b8427e30779aba23
Tested this branch and didn’t see the null pointer error. The change to std::byte is for modernization and the change to std::ranges addresses the issue.
dergoegge approved
dergoegge
commented at 9:54 am on October 31, 2025:
member
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2025-11-20 15:13 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me