Selaa lähdekoodia

loader: add type index checking (#4521)

Zhenwei Jin 7 kuukautta sitten
vanhempi
sitoutus
378320b886
1 muutettua tiedostoa jossa 2 lisäystä ja 1 poistoa
  1. 2 1
      core/iwasm/aot/aot_loader.c

+ 2 - 1
core/iwasm/aot/aot_loader.c

@@ -1786,7 +1786,8 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
 
             read_uint32(buf, buf_end, j);
 #if WASM_ENABLE_AOT_VALIDATOR != 0
-            if (j >= module->type_count) {
+            /* an equivalence type should be before the type it refers to */
+            if (j > i) {
                 set_error_buf(error_buf, error_buf_size, "invalid type index");
                 goto fail;
             }