In the master branch @ fb85bb277670aad28fef51b7313d4a96cdaa760f, the following code in the DecodeScript function: https://github.com/bitcoin/bitcoin/blob/fb85bb277670aad28fef51b7313d4a96cdaa760f/src/script/miniscript.h#L2312-L2313 explicitly passes 33 bytes to the TapSatisfier::FromPKHBytes function, which expects 32 bytes only: https://github.com/bitcoin/bitcoin/blob/fb85bb277670aad28fef51b7313d4a96cdaa760f/src/script/sign.cpp#L295-L302
An overflow in `TapSatisfier::FromPKHBytes`? #28871
issue hebasto opened this issue on November 14, 2023-
hebasto commented at 12:28 PM on November 14, 2023: member
-
sipa commented at 12:30 PM on November 14, 2023: member
Not an issue; if this runs in tapscript context, the code will bail out before reaching this line.
-
hebasto commented at 12:35 PM on November 14, 2023: member
Right. But a compiler might be not aware of that:
/usr/include/c++/11/bits/stl_algobase.h:431: warning: '__builtin_memcpy' writing 33 bytes into a region of size 32 overflows the destination [-Wstringop-overflow=] 431 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num); | /usr/include/c++/11/bits/stl_algobase.h: In function 'DecodeScript': script/sign.cpp:299:21: note: destination object 'pubkey' of size 32 299 | XOnlyPubKey pubkey; | ^ -
fanquake commented at 2:00 PM on November 14, 2023: member
I'm assuming this is with GCC 11 under LTO? I'd suggest using a newer, "smarter" compiler. The same warnings don't appear under GCC 13.
- hebasto closed this on Nov 14, 2023
- bitcoin locked this on Nov 13, 2024