Skip to content

Commit 7531195

Browse files
committed
Fix off-by-one
1 parent 66ca1a3 commit 7531195

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

examples/Wasm_Blink/Wasm_Blink.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void wasm_task(void*)
178178
#endif
179179

180180
IM3Module module;
181-
result = m3_ParseModule (env, &module, app_wasm, app_wasm_len-1);
181+
result = m3_ParseModule (env, &module, app_wasm, app_wasm_len);
182182
if (result) FATAL("ParseModule", result);
183183

184184
result = m3_LoadModule (runtime, module);

examples/Wasm_Fibonacci/Wasm_Fibonacci.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void wasm_task(void*)
4848
if (!runtime) FATAL("NewRuntime", "failed");
4949

5050
IM3Module module;
51-
result = m3_ParseModule (env, &module, fib_wasm, sizeof(fib_wasm)-1);
51+
result = m3_ParseModule (env, &module, fib_wasm, sizeof(fib_wasm));
5252
if (result) FATAL("ParseModule", result);
5353

5454
result = m3_LoadModule (runtime, module);
@@ -117,3 +117,4 @@ void loop()
117117
{
118118
delay(100);
119119
}
120+

examples_pio/Wasm_Advanced/wasm_vm/wasm_vm.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void wasm_task(void*)
172172
#endif
173173

174174
IM3Module module;
175-
result = m3_ParseModule (env, &module, app_wasm, app_wasm_len-1);
175+
result = m3_ParseModule (env, &module, app_wasm, app_wasm_len);
176176
if (result) FATAL("ParseModule", result);
177177

178178
result = m3_LoadModule (runtime, module);

src/m3_parse.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ _ (ReadLEB_u7 (& section, & pos, end));
570570
{
571571
u32 sectionLength;
572572
_ (ReadLEB_u32 (& sectionLength, & pos, end));
573+
_throwif(m3Err_wasmMalformed, pos + sectionLength > end);
573574
_ (ParseModuleSection (module, section, pos, sectionLength));
574575

575576
pos += sectionLength;

0 commit comments

Comments
 (0)