Skip to content

Commit fa84e6c

Browse files
author
MarcoFalke
committed
bitcoin-tx: Reject + sign in MutateTxDel*
1 parent face251 commit fa84e6c

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/bitcoin-tx.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -507,26 +507,20 @@ static void MutateTxAddOutScript(CMutableTransaction& tx, const std::string& str
507507

508508
static void MutateTxDelInput(CMutableTransaction& tx, const std::string& strInIdx)
509509
{
510-
// parse requested deletion index
511-
int64_t inIdx;
512-
if (!ParseInt64(strInIdx, &inIdx) || inIdx < 0 || inIdx >= static_cast<int64_t>(tx.vin.size())) {
510+
const auto idx{ToIntegral<uint32_t>(strInIdx)};
511+
if (!idx || idx >= tx.vin.size()) {
513512
throw std::runtime_error("Invalid TX input index '" + strInIdx + "'");
514513
}
515-
516-
// delete input from transaction
517-
tx.vin.erase(tx.vin.begin() + inIdx);
514+
tx.vin.erase(tx.vin.begin() + *idx);
518515
}
519516

520517
static void MutateTxDelOutput(CMutableTransaction& tx, const std::string& strOutIdx)
521518
{
522-
// parse requested deletion index
523-
int64_t outIdx;
524-
if (!ParseInt64(strOutIdx, &outIdx) || outIdx < 0 || outIdx >= static_cast<int64_t>(tx.vout.size())) {
519+
const auto idx{ToIntegral<uint32_t>(strOutIdx)};
520+
if (!idx || idx >= tx.vout.size()) {
525521
throw std::runtime_error("Invalid TX output index '" + strOutIdx + "'");
526522
}
527-
528-
// delete output from transaction
529-
tx.vout.erase(tx.vout.begin() + outIdx);
523+
tx.vout.erase(tx.vout.begin() + *idx);
530524
}
531525

532526
static const unsigned int N_SIGHASH_OPTS = 7;

0 commit comments

Comments
 (0)