mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Various ubsan fixes
Mostly harmless signed/unsigned conversions but also an actual memory leak related to `BlindingData`.
This commit is contained in:
parent
f1092db80e
commit
14ff891036
6 changed files with 18 additions and 13 deletions
|
|
@ -31,7 +31,6 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
|||
|
||||
try {
|
||||
const CTransaction tx(deserialize, ds);
|
||||
tx.witness.vtxinwit.resize(tx.vin.size());
|
||||
|
||||
unsigned int verify_flags;
|
||||
ds >> verify_flags;
|
||||
|
|
@ -55,7 +54,8 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
|||
const TransactionSignatureChecker checker{&tx, i, prevout.nValue, txdata};
|
||||
|
||||
ScriptError serror;
|
||||
const bool ret = VerifyScript(tx.vin.at(i).scriptSig, prevout.scriptPubKey, &tx.witness.vtxinwit.at(i).scriptWitness, verify_flags, checker, &serror);
|
||||
const CScriptWitness *script_witness = tx.witness.vtxinwit.size() > i ? &tx.witness.vtxinwit[i].scriptWitness : nullptr;
|
||||
const bool ret = VerifyScript(tx.vin.at(i).scriptSig, prevout.scriptPubKey, script_witness, verify_flags, checker, &serror);
|
||||
assert(ret == (serror == SCRIPT_ERR_OK));
|
||||
|
||||
// Verify that removing flags from a passing test or adding flags to a failing test does not change the result
|
||||
|
|
@ -67,7 +67,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
|||
if (!IsValidFlagCombination(verify_flags)) return;
|
||||
|
||||
ScriptError serror_fuzzed;
|
||||
const bool ret_fuzzed = VerifyScript(tx.vin.at(i).scriptSig, prevout.scriptPubKey, &tx.witness.vtxinwit.at(i).scriptWitness, verify_flags, checker, &serror_fuzzed);
|
||||
const bool ret_fuzzed = VerifyScript(tx.vin.at(i).scriptSig, prevout.scriptPubKey, script_witness, verify_flags, checker, &serror_fuzzed);
|
||||
assert(ret_fuzzed == (serror_fuzzed == SCRIPT_ERR_OK));
|
||||
|
||||
assert(ret_fuzzed == ret);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue