mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 15:05:19 +00:00
Add more checks in wasm loader (#3300)
In opcode f32.const, f64.const and memory.copy, check whether the buffer to read is out of the range of wasm file before reading it.
This commit is contained in:
parent
19a6eb98b0
commit
1c690b7561
|
@ -13008,6 +13008,7 @@ re_scan:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WASM_OP_F32_CONST:
|
case WASM_OP_F32_CONST:
|
||||||
|
CHECK_BUF(p, p_end, sizeof(float32));
|
||||||
p += sizeof(float32);
|
p += sizeof(float32);
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
skip_label();
|
skip_label();
|
||||||
|
@ -13026,6 +13027,7 @@ re_scan:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WASM_OP_F64_CONST:
|
case WASM_OP_F64_CONST:
|
||||||
|
CHECK_BUF(p, p_end, sizeof(float64));
|
||||||
p += sizeof(float64);
|
p += sizeof(float64);
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
skip_label();
|
skip_label();
|
||||||
|
@ -14356,6 +14358,7 @@ re_scan:
|
||||||
}
|
}
|
||||||
case WASM_OP_MEMORY_COPY:
|
case WASM_OP_MEMORY_COPY:
|
||||||
{
|
{
|
||||||
|
CHECK_BUF(p, p_end, sizeof(int16));
|
||||||
/* both src and dst memory index should be 0 */
|
/* both src and dst memory index should be 0 */
|
||||||
if (*(int16 *)p != 0x0000)
|
if (*(int16 *)p != 0x0000)
|
||||||
goto fail_zero_byte_expected;
|
goto fail_zero_byte_expected;
|
||||||
|
|
|
@ -7351,6 +7351,7 @@ re_scan:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WASM_OP_F32_CONST:
|
case WASM_OP_F32_CONST:
|
||||||
|
CHECK_BUF(p, p_end, sizeof(float32));
|
||||||
p += sizeof(float32);
|
p += sizeof(float32);
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
skip_label();
|
skip_label();
|
||||||
|
@ -7369,6 +7370,7 @@ re_scan:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WASM_OP_F64_CONST:
|
case WASM_OP_F64_CONST:
|
||||||
|
CHECK_BUF(p, p_end, sizeof(float64));
|
||||||
p += sizeof(float64);
|
p += sizeof(float64);
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
skip_label();
|
skip_label();
|
||||||
|
@ -7676,6 +7678,7 @@ re_scan:
|
||||||
}
|
}
|
||||||
case WASM_OP_MEMORY_COPY:
|
case WASM_OP_MEMORY_COPY:
|
||||||
{
|
{
|
||||||
|
CHECK_BUF(p, p_end, sizeof(int16));
|
||||||
/* both src and dst memory index should be 0 */
|
/* both src and dst memory index should be 0 */
|
||||||
bh_assert(*(int16 *)p == 0x0000);
|
bh_assert(*(int16 *)p == 0x0000);
|
||||||
p += 2;
|
p += 2;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user