Skip to content

Commit 6621793

Browse files
authored
Fix two fuzz issues (#3529)
- #69598: protect from `0-1` - #69608: in case no tailing `\0`
1 parent f844b33 commit 6621793

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

core/iwasm/aot/aot_loader.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,18 @@ load_string(uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
326326
/* The string is always terminated with '\0', use it directly.
327327
* In this case, the file buffer can be referred to after loading.
328328
*/
329-
bh_assert(p[str_len - 1] == '\0');
329+
if (p[str_len - 1] != '\0')
330+
goto fail;
331+
330332
str = (char *)p;
331333
}
332334
else {
333335
/* Load from sections, the file buffer cannot be referred to
334336
after loading, we must create another string and insert it
335337
into const string set */
336-
bh_assert(p[str_len - 1] == '\0');
338+
if (p[str_len - 1] != '\0')
339+
goto fail;
340+
337341
if (!(str = aot_const_str_set_insert((uint8 *)p, str_len, module,
338342
#if (WASM_ENABLE_WORD_ALIGN_READ != 0)
339343
is_vram_word_align,
@@ -568,7 +572,7 @@ get_native_symbol_by_name(const char *name)
568572

569573
sym = get_target_symbol_map(&symnum);
570574

571-
while (symnum--) {
575+
while (symnum && symnum--) {
572576
if (strcmp(sym->symbol_name, name) == 0) {
573577
func = sym->symbol_addr;
574578
break;

0 commit comments

Comments
 (0)