mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Fix check_underflow in some instructions
This commit is contained in:
parent
ce58805104
commit
f03f6ce7ca
3 changed files with 15 additions and 4 deletions
|
@ -279,6 +279,7 @@ int exec_get_global_id(VmState* st) {
|
|||
int exec_get_gas_fee(VmState* st) {
|
||||
VM_LOG(st) << "execute GETGASFEE";
|
||||
Stack& stack = st->get_stack();
|
||||
stack.check_underflow(st->get_global_version() >= 9 ? 2 : 0);
|
||||
bool is_masterchain = stack.pop_bool();
|
||||
td::uint64 gas = stack.pop_long_range(std::numeric_limits<td::int64>::max(), 0);
|
||||
block::GasLimitsPrices prices = util::get_gas_prices(get_unpacked_config_tuple(st), is_masterchain);
|
||||
|
@ -289,6 +290,7 @@ int exec_get_gas_fee(VmState* st) {
|
|||
int exec_get_storage_fee(VmState* st) {
|
||||
VM_LOG(st) << "execute GETSTORAGEFEE";
|
||||
Stack& stack = st->get_stack();
|
||||
stack.check_underflow(st->get_global_version() >= 9 ? 4 : 0);
|
||||
bool is_masterchain = stack.pop_bool();
|
||||
td::int64 delta = stack.pop_long_range(std::numeric_limits<td::int64>::max(), 0);
|
||||
td::uint64 bits = stack.pop_long_range(std::numeric_limits<td::int64>::max(), 0);
|
||||
|
@ -302,6 +304,7 @@ int exec_get_storage_fee(VmState* st) {
|
|||
int exec_get_forward_fee(VmState* st) {
|
||||
VM_LOG(st) << "execute GETFORWARDFEE";
|
||||
Stack& stack = st->get_stack();
|
||||
stack.check_underflow(st->get_global_version() >= 9 ? 3 : 0);
|
||||
bool is_masterchain = stack.pop_bool();
|
||||
td::uint64 bits = stack.pop_long_range(std::numeric_limits<td::int64>::max(), 0);
|
||||
td::uint64 cells = stack.pop_long_range(std::numeric_limits<td::int64>::max(), 0);
|
||||
|
@ -320,6 +323,7 @@ int exec_get_precompiled_gas(VmState* st) {
|
|||
int exec_get_original_fwd_fee(VmState* st) {
|
||||
VM_LOG(st) << "execute GETORIGINALFWDFEE";
|
||||
Stack& stack = st->get_stack();
|
||||
stack.check_underflow(st->get_global_version() >= 9 ? 2 : 0);
|
||||
bool is_masterchain = stack.pop_bool();
|
||||
td::RefInt256 fwd_fee = stack.pop_int_finite();
|
||||
if (fwd_fee->sgn() < 0) {
|
||||
|
@ -333,6 +337,7 @@ int exec_get_original_fwd_fee(VmState* st) {
|
|||
int exec_get_gas_fee_simple(VmState* st) {
|
||||
VM_LOG(st) << "execute GETGASFEESIMPLE";
|
||||
Stack& stack = st->get_stack();
|
||||
stack.check_underflow(st->get_global_version() >= 9 ? 2 : 0);
|
||||
bool is_masterchain = stack.pop_bool();
|
||||
td::uint64 gas = stack.pop_long_range(std::numeric_limits<td::int64>::max(), 0);
|
||||
block::GasLimitsPrices prices = util::get_gas_prices(get_unpacked_config_tuple(st), is_masterchain);
|
||||
|
@ -343,6 +348,7 @@ int exec_get_gas_fee_simple(VmState* st) {
|
|||
int exec_get_forward_fee_simple(VmState* st) {
|
||||
VM_LOG(st) << "execute GETFORWARDFEESIMPLE";
|
||||
Stack& stack = st->get_stack();
|
||||
stack.check_underflow(st->get_global_version() >= 9 ? 3 : 0);
|
||||
bool is_masterchain = stack.pop_bool();
|
||||
td::uint64 bits = stack.pop_long_range(std::numeric_limits<td::int64>::max(), 0);
|
||||
td::uint64 cells = stack.pop_long_range(std::numeric_limits<td::int64>::max(), 0);
|
||||
|
@ -373,6 +379,7 @@ void register_ton_config_ops(OpcodeTable& cp0) {
|
|||
.insert(OpcodeInstr::mksimple(0xf833, 16, "CONFIGOPTPARAM", std::bind(exec_get_config_param, _1, true)))
|
||||
.insert(OpcodeInstr::mksimple(0xf83400, 24, "PREVMCBLOCKS", std::bind(exec_get_prev_blocks_info, _1, 0, "PREVMCBLOCKS"))->require_version(4))
|
||||
.insert(OpcodeInstr::mksimple(0xf83401, 24, "PREVKEYBLOCK", std::bind(exec_get_prev_blocks_info, _1, 1, "PREVKEYBLOCK"))->require_version(4))
|
||||
.insert(OpcodeInstr::mksimple(0xf83402, 24, "PREVMCBLOCKS_100", std::bind(exec_get_prev_blocks_info, _1, 2, "PREVMCBLOCKS_100"))->require_version(9))
|
||||
.insert(OpcodeInstr::mksimple(0xf835, 16, "GLOBALID", exec_get_global_id)->require_version(4))
|
||||
.insert(OpcodeInstr::mksimple(0xf836, 16, "GETGASFEE", exec_get_gas_fee)->require_version(6))
|
||||
.insert(OpcodeInstr::mksimple(0xf837, 16, "GETSTORAGEFEE", exec_get_storage_fee)->require_version(6))
|
||||
|
@ -538,9 +545,10 @@ int exec_hash_ext(VmState* st, unsigned args) {
|
|||
VM_LOG(st) << "execute HASHEXT" << (append ? "A" : "") << (rev ? "R" : "") << " " << (hash_id == 255 ? -1 : hash_id);
|
||||
Stack& stack = st->get_stack();
|
||||
if (hash_id == 255) {
|
||||
stack.check_underflow(st->get_global_version() >= 9 ? 2 : 0);
|
||||
hash_id = stack.pop_smallint_range(254);
|
||||
}
|
||||
int cnt = stack.pop_smallint_range(stack.depth() - 1);
|
||||
int cnt = stack.pop_smallint_range(stack.depth() - 1 - (st->get_global_version() >= 9 ? (int)append : 0));
|
||||
Hasher hasher{hash_id};
|
||||
size_t total_bits = 0;
|
||||
long long gas_consumed = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue