From af251e45ca3eb7478f3c625e73c1a9825d387050 Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Mon, 20 Dec 2021 19:22:28 +0800 Subject: [PATCH] Remove PRI macro control in wasm_application.c (#905) And fix read_leb byte count check issue in aot_compiler.c --- core/iwasm/common/wasm_application.c | 18 ------------------ core/iwasm/compilation/aot_compiler.c | 5 +++-- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/core/iwasm/common/wasm_application.c b/core/iwasm/common/wasm_application.c index 3f4465fb7..326f008db 100644 --- a/core/iwasm/common/wasm_application.c +++ b/core/iwasm/common/wasm_application.c @@ -586,16 +586,7 @@ wasm_application_execute_func(WASMModuleInstanceCommon *module_inst, u.parts[0] = argv1[k]; u.parts[1] = argv1[k + 1]; k += 2; -#ifdef PRIx64 os_printf("0x%" PRIx64 ":i64", u.val); -#else - char buf[16]; - if (sizeof(long) == 4) - snprintf(buf, sizeof(buf), "%s", "0x%llx:i64"); - else - snprintf(buf, sizeof(buf), "%s", "0x%lx:i64"); - os_printf(buf, u.val); -#endif break; } case VALUE_TYPE_F32: @@ -645,17 +636,8 @@ wasm_application_execute_func(WASMModuleInstanceCommon *module_inst, case VALUE_TYPE_V128: { uint64 *v = (uint64 *)(argv1 + k); -#if defined(PRIx64) os_printf("<0x%016" PRIx64 " 0x%016" PRIx64 ">:v128", *v, *(v + 1)); -#else - if (4 == sizeof(long)) { - os_printf("<0x%016llx 0x%016llx>:v128", *v, *(v + 1)); - } - else { - os_printf("<0x%016lx 0x%016lx>:v128", *v, *(v + 1)); - } -#endif /* PRIx64 */ k += 4; break; } diff --git a/core/iwasm/compilation/aot_compiler.c b/core/iwasm/compilation/aot_compiler.c index 0eacfa640..9e8396012 100644 --- a/core/iwasm/compilation/aot_compiler.c +++ b/core/iwasm/compilation/aot_compiler.c @@ -64,8 +64,9 @@ read_leb(const uint8 *buf, const uint8 *buf_end, uint32 *p_offset, } bcnt += 1; } - if (bcnt > (((maxbits + 8) >> 3) - (maxbits + 8))) { - aot_set_last_error("read leb failed: unsigned leb overflow."); + if (bcnt > (maxbits + 6) / 7) { + aot_set_last_error("read leb failed: " + "integer representation too long"); return false; } if (sign && (shift < maxbits) && (byte & 0x40)) {