mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Disallow recursive library cells (#868)
* Disallow recursive library cells * Stop emulation of external messages on accept --------- Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
128a85bee5
commit
42d4c051ef
7 changed files with 50 additions and 0 deletions
|
@ -892,6 +892,37 @@ int exec_load_special_cell(VmState* st, bool quiet) {
|
|||
Stack& stack = st->get_stack();
|
||||
VM_LOG(st) << "execute XLOAD" << (quiet ? "Q" : "");
|
||||
auto cell = stack.pop_cell();
|
||||
auto r_loaded_cell = cell->load_cell();
|
||||
if (r_loaded_cell.is_error()) {
|
||||
if (quiet) {
|
||||
stack.push_bool(false);
|
||||
return 0;
|
||||
} else {
|
||||
throw VmError{Excno::cell_und, "failed to load cell"};
|
||||
}
|
||||
}
|
||||
auto loaded_cell = r_loaded_cell.move_as_ok();
|
||||
if (loaded_cell.data_cell->is_special()) {
|
||||
if (loaded_cell.data_cell->special_type() != CellTraits::SpecialType::Library) {
|
||||
if (quiet) {
|
||||
stack.push_bool(false);
|
||||
return 0;
|
||||
} else {
|
||||
throw VmError{Excno::cell_und, "unexpected special cell"};
|
||||
}
|
||||
}
|
||||
CellSlice cs(std::move(loaded_cell));
|
||||
DCHECK(cs.size() == Cell::hash_bits + 8);
|
||||
cell = st->load_library(cs.data_bits() + 8);
|
||||
if (cell.is_null()) {
|
||||
if (quiet) {
|
||||
stack.push_bool(false);
|
||||
return 0;
|
||||
} else {
|
||||
throw VmError{Excno::cell_und, "failed to load library cell"};
|
||||
}
|
||||
}
|
||||
}
|
||||
stack.push_cell(cell);
|
||||
if (quiet) {
|
||||
stack.push_bool(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue