mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
fix: Make TxidFromString() respect string_view length
Prior to this, passing string_view::data() into uint256S() meant the latter would only receive the a naked char* pointer and potentially scan past the string_view::length() until it found a null terminator (or some other non-hex character). Appears to have been a fully dormant bug as callers were either passing a string literal or std::string directly to TxidFromFromString(), meaning null terminator always existed at pointer[length()]. Bug existed since original merge of TxidFromString(), discussed in https://github.com/bitcoin/bitcoin/pull/28922#discussion_r1404437378.
This commit is contained in:
@@ -47,7 +47,7 @@ inline CTransactionRef create_placeholder_tx(size_t num_inputs, size_t num_outpu
|
||||
// Create a Wtxid from a hex string
|
||||
inline Wtxid WtxidFromString(std::string_view str)
|
||||
{
|
||||
return Wtxid::FromUint256(uint256S(str.data()));
|
||||
return Wtxid::FromUint256(uint256S(str));
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(package_hash_tests, TestChain100Setup)
|
||||
|
||||
Reference in New Issue
Block a user