check accessing an element past the end of a container

This commit is contained in:
moneromooo-monero 2017-12-12 11:08:11 +00:00
parent 2305bf260d
commit b49ddc766d
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
8 changed files with 46 additions and 12 deletions

View file

@ -486,7 +486,7 @@ namespace tools
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::validate_transfer(const std::list<wallet_rpc::transfer_destination>& destinations, const std::string& payment_id, std::vector<cryptonote::tx_destination_entry>& dsts, std::vector<uint8_t>& extra, epee::json_rpc::error& er)
bool wallet_rpc_server::validate_transfer(const std::list<wallet_rpc::transfer_destination>& destinations, const std::string& payment_id, std::vector<cryptonote::tx_destination_entry>& dsts, std::vector<uint8_t>& extra, bool at_least_one_destination, epee::json_rpc::error& er)
{
crypto::hash8 integrated_payment_id = crypto::null_hash8;
std::string extra_nonce;
@ -541,6 +541,13 @@ namespace tools
}
}
if (at_least_one_destination && dsts.empty())
{
er.code = WALLET_RPC_ERROR_CODE_ZERO_DESTINATION;
er.message = "No destinations for this transfer";
return false;
}
if (!payment_id.empty())
{
@ -592,7 +599,7 @@ namespace tools
}
// validate the transfer requested and populate dsts & extra
if (!validate_transfer(req.destinations, req.payment_id, dsts, extra, er))
if (!validate_transfer(req.destinations, req.payment_id, dsts, extra, true, er))
{
return false;
}
@ -690,7 +697,7 @@ namespace tools
}
// validate the transfer requested and populate dsts & extra; RPC_TRANSFER::request and RPC_TRANSFER_SPLIT::request are identical types.
if (!validate_transfer(req.destinations, req.payment_id, dsts, extra, er))
if (!validate_transfer(req.destinations, req.payment_id, dsts, extra, true, er))
{
return false;
}
@ -887,7 +894,7 @@ namespace tools
destination.push_back(wallet_rpc::transfer_destination());
destination.back().amount = 0;
destination.back().address = req.address;
if (!validate_transfer(destination, req.payment_id, dsts, extra, er))
if (!validate_transfer(destination, req.payment_id, dsts, extra, true, er))
{
return false;
}
@ -986,7 +993,7 @@ namespace tools
destination.push_back(wallet_rpc::transfer_destination());
destination.back().amount = 0;
destination.back().address = req.address;
if (!validate_transfer(destination, req.payment_id, dsts, extra, er))
if (!validate_transfer(destination, req.payment_id, dsts, extra, true, er))
{
return false;
}