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
<!--e57a25ab6845829454e8d69fc972939a-->
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
utACKfa4b52bd16189d40761c5976b8427e30779aba23
fanquake merged this on Oct 31, 2025
fanquake closed this on Oct 31, 2025
maflcko deleted the branch on Oct 31, 2025
sedited referenced this in commit c4d4877626 on Nov 5, 2025
stickies-v referenced this in commit a785fe6759 on Nov 5, 2025
stringintech referenced this in commit b82132c4d1 on Nov 6, 2025
yuvicc referenced this in commit f620a2206b on Nov 16, 2025
Kino1994 referenced this in commit 372ff73db9 on Jun 28, 2026
BigcoinBGC referenced this in commit 717b3adfa1 on Jun 30, 2026
Kino1994 referenced this in commit 78ffb55e73 on Aug 19, 2026
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: 2026-11-18 16:51 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me