From 27b7c562cb8b1c5e93ac40320615ba873fd4ba11 Mon Sep 17 00:00:00 2001 From: fractasy Date: Wed, 28 Aug 2024 12:01:19 +0000 Subject: [PATCH] Fix FullTracer getFromMemory() to filter lengths that are too high --- src/main_sm/fork_9/main/full_tracer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main_sm/fork_9/main/full_tracer.cpp b/src/main_sm/fork_9/main/full_tracer.cpp index 4d34d0424..8ffac0920 100644 --- a/src/main_sm/fork_9/main/full_tracer.cpp +++ b/src/main_sm/fork_9/main/full_tracer.cpp @@ -108,6 +108,14 @@ inline zkresult getFromMemory(Context &ctx, mpz_class &offset, mpz_class &length uint64_t addrMem = offsetCtx + 0x20000; result = ""; + + // If length is too high this is due to an OOG that will stop processing; just pretend to have read nothing + if (length > ctx.rom.constants.MAX_MEM_EXPANSION_BYTES) + { + zklog.error("getFromMemory() got length=" + length.get_str(10) + " > rom.constants.MAX_MEM_EXPANSION_BYTES=" + to_string(ctx.rom.constants.MAX_MEM_EXPANSION_BYTES)); + return ZKR_SUCCESS; + } + double init = addrMem + double(offset.get_ui()) / 32; double end = addrMem + double(offset.get_ui() + length.get_ui()) / 32; uint64_t initCeil = ceil(init);