maflcko
commented at 6:46 pm on January 14, 2025:
member
It is UB to apply a distance to a pointer or iterator further than the
end itself, even if the distance is (partially) revoked later on.
Fix the issue by advancing the data pointer at most to the end.
This fix is required to adopt C++ safe buffers #31272.
Also included is a somewhat unrelated commit.
refactor: Drop unused UCharCast
This is no longer needed after commit
6aa0e70ccbd5491ec9d7c81892820f3341ccd631
fad4032b21
refactor: Avoid UB in SHA3_256::Write
It is UB to apply a distance to a pointer or iterator further than the
end itself, even if the distance is (partially) revoked later on.
Fix the issue by advancing the data pointer at most to the end.
fabeca3458
DrahtBot
commented at 6:46 pm on January 14, 2025:
contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
DrahtBot renamed this:
refactor: Avoid UB in SHA3_256::Write
refactor: Avoid UB in SHA3_256::Write
on Jan 14, 2025
DrahtBot added the label
Refactoring
on Jan 14, 2025
maflcko
commented at 6:48 pm on January 14, 2025:
member
I tested with g++-14 and the resulting bitcoind was unchanged, so I tagged this as “refactor”. However, this may not hold for every compiler and build setting.
sipa
commented at 6:56 pm on January 14, 2025:
member
utACKfabeca3458b38a3d8930cb0cbc866388c3f120f1
maflcko
commented at 8:10 pm on January 14, 2025:
member
On master it fails when running MAKEJOBS="-j$(nproc)" FILE_ENV="./ci/test/00_setup_env_native_msan.sh" ./ci/test_run_all.sh. On this pull, it should pass.
theuni approved
theuni
commented at 10:15 pm on January 14, 2025:
member
utACKfabeca3458b38a3d8930cb0cbc866388c3f120f1
maflcko added this to the milestone 29.0
on Jan 15, 2025
hebasto
commented at 10:51 am on January 16, 2025:
member
It is UB to apply a distance to a pointer or iterator further than the end itself, even if the distance is (partially) revoked later on.
I’m not arguing with this change, but could someone provide a quote from the C++20 standard that stipulates this? From my reading of the standard, it appears that only dereferencing causes UB in such cases.
maflcko
commented at 11:13 am on January 16, 2025:
member
It is UB to apply a distance to a pointer or iterator further than the end itself, even if the distance is (partially) revoked later on.
I’m not arguing with this change, but could someone provide a quote from the C++20 standard that stipulates this? From my reading of the standard, it appears that only dereferencing causes UB in such cases.
When an expression J that has integral type is added to […] an expression P of pointer type, the result has the type of P.
… if P points to a (possibly-hypothetical) array element i of an array object x with n elements […] the expressions P + J and J + P (where J has the value j) point to the (possibly-hypothetical) array element i+j of x if 0≤i+j≤n […]
Otherwise, the behavior is undefined.
Note: In the context of Span, an iterator is a pointer.
hebasto
commented at 11:39 am on January 16, 2025:
member
On master it fails when running MAKEJOBS="-j$(nproc)" FILE_ENV="./ci/test/00_setup_env_native_msan.sh" ./ci/test_run_all.sh. On this pull, it should pass.
I can confirm this.
hebasto approved
hebasto
commented at 11:42 am on January 16, 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-01-21 03:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me