Skip to content

Commit ab2ff4a

Browse files
authored
add rec idx and rec count validation in aot loader (#4555)
Signed-off-by: zhenweijin <zhenwei.jin@intel.com>
1 parent d0c636b commit ab2ff4a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/iwasm/aot/aot_loader.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,8 +1807,12 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
18071807
read_uint16(buf, buf_end, rec_count);
18081808
read_uint16(buf, buf_end, rec_idx);
18091809
#if WASM_ENABLE_AOT_VALIDATOR != 0
1810-
if (rec_idx > i) {
1811-
set_error_buf(error_buf, error_buf_size, "invalid rec_idx");
1810+
if (rec_count > module->type_count) {
1811+
set_error_buf(error_buf, error_buf_size, "invalid rec count");
1812+
goto fail;
1813+
}
1814+
if (rec_idx > i || rec_idx >= rec_count) {
1815+
set_error_buf(error_buf, error_buf_size, "invalid rec idx");
18121816
goto fail;
18131817
}
18141818
if (parent_type_idx >= i) {

0 commit comments

Comments
 (0)