bitcoin-tx: Reject non-integral and out of range multisig numbers

This commit is contained in:
MarcoFalke 2021-10-11 14:33:38 +02:00
parent fafab8ea5e
commit fa6f29de51
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548
2 changed files with 14 additions and 2 deletions

View File

@ -363,10 +363,10 @@ static void MutateTxAddOutMultiSig(CMutableTransaction& tx, const std::string& s
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
// Extract REQUIRED
uint32_t required = stoul(vStrInputParts[1]);
const uint32_t required{TrimAndParse<uint32_t>(vStrInputParts.at(1), "invalid multisig required number")};
// Extract NUMKEYS
uint32_t numkeys = stoul(vStrInputParts[2]);
const uint32_t numkeys{TrimAndParse<uint32_t>(vStrInputParts.at(2), "invalid multisig total number")};
// Validate there are the correct number of pubkeys
if (vStrInputParts.size() < numkeys + 3)

View File

@ -579,6 +579,18 @@
"output_cmp": "txcreatedata_seq1.json",
"description": "Adds a new input with sequence number to a transaction (output in json)"
},
{ "exec": "./bitcoin-tx",
"args": ["-create", "outmultisig=1:-2:3:02a5:021:02df", "nversion=1"],
"return_code": 1,
"error_txt": "error: invalid multisig required number '-2'",
"description": "Try to parse a multisig number outside the allowed range"
},
{ "exec": "./bitcoin-tx",
"args": ["-create", "outmultisig=1:2:3a:02a5:021:02df", "nversion=1"],
"return_code": 1,
"error_txt": "error: invalid multisig total number '3a'",
"description": "Try to parse a multisig number outside the allowed range"
},
{ "exec": "./bitcoin-tx",
"args": ["-create", "outmultisig=1:2:3:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d:02df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb485", "nversion=1"],
"output_cmp": "txcreatemultisig1.hex",