mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 15:50:07 +01:00
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()
Github-Pull: #10130
Rebased-From: eb66bf9bdd
This commit is contained in:
committed by
Wladimir J. van der Laan
parent
b768202695
commit
04c21afcdf
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user