Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #8344 from EOSIO/fixes
Browse files Browse the repository at this point in the history
Consolidated Security Fixes for 2.0.x
  • Loading branch information
larryk85 authored Dec 17, 2019
2 parents 0daaa41 + a3af39f commit faf020b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
3 changes: 3 additions & 0 deletions libraries/chain/webassembly/eos-vm-oc/compile_trampoline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ void run_compile(wrapped_fd&& response_sock, wrapped_fd&& wasm_code) noexcept {
for(const TableSegment& table_segment : module.tableSegments) {
struct table_entry* table_index_0 = (struct table_entry*)&*prologue_it;

if(table_segment.baseOffset.i32 > module.tables.defs[0].type.size.min)
return;

for(Uptr i = 0; i < table_segment.indices.size(); ++i) {
const Uptr function_index = table_segment.indices[i];
const long int effective_table_index = table_segment.baseOffset.i32 + i;
Expand Down
10 changes: 1 addition & 9 deletions libraries/chain/webassembly/eos-vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,8 @@ class eos_vm_instantiated_module : public wasm_instantiated_module_interface {
void apply(apply_context& context) override {
_instantiated_module->set_wasm_allocator(&context.control.get_wasm_allocator());
_runtime->_bkend = _instantiated_module.get();
_runtime->_bkend->initialize(&context);
// clamp WASM memory to maximum_linear_memory/wasm_page_size
auto& module = _runtime->_bkend->get_module();
if (module.memories.size() &&
((module.memories.at(0).limits.maximum > wasm_constraints::maximum_linear_memory / wasm_constraints::wasm_page_size)
|| !module.memories.at(0).limits.flags)) {
module.memories.at(0).limits.flags = true;
module.memories.at(0).limits.maximum = wasm_constraints::maximum_linear_memory / wasm_constraints::wasm_page_size;
}
auto fn = [&]() {
_runtime->_bkend->initialize(&context);
const auto& res = _runtime->_bkend->call(
&context, "env", "apply", context.get_receiver().to_uint64_t(),
context.get_action().account.to_uint64_t(),
Expand Down
2 changes: 1 addition & 1 deletion libraries/eos-vm

0 comments on commit faf020b

Please sign in to comment.