bitcoin-tx: Fix missing range check
The number of arguments is not checked MutateTxAddOutAddr(..), meaning that > ./bitcoin-tx -create outaddr= accessed the vStrInputParts vector beyond its bounds. This also includes work by jnewbery to check the inputs for MutateTxAddPubKey()
This commit is contained in:
parent
0b9fb68289
commit
eb66bf9bdd
1 changed files with 6 additions and 0 deletions
|
@ -242,6 +242,9 @@ static void MutateTxAddOutAddr(CMutableTransaction& tx, const std::string& strIn
|
|||
std::vector<std::string> vStrInputParts;
|
||||
boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
|
||||
|
||||
if (vStrInputParts.size() != 2)
|
||||
throw std::runtime_error("TX output missing or too many separators");
|
||||
|
||||
// Extract and validate VALUE
|
||||
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
|
||||
|
||||
|
@ -264,6 +267,9 @@ static void MutateTxAddOutPubKey(CMutableTransaction& tx, const std::string& str
|
|||
std::vector<std::string> vStrInputParts;
|
||||
boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
|
||||
|
||||
if (vStrInputParts.size() < 2 || vStrInputParts.size() > 3)
|
||||
throw std::runtime_error("TX output missing or too many separators");
|
||||
|
||||
// Extract and validate VALUE
|
||||
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue