mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-09 05:06:17 +00:00
aot compiler: Bail out on too long native symbol names (#3663)
The old code was silently truncating long names.
This commit is contained in:
parent
a055e0b26f
commit
2f147fae96
|
@ -3277,6 +3277,7 @@ static bool
|
||||||
insert_native_symbol(AOTCompContext *comp_ctx, const char *symbol, int32 idx)
|
insert_native_symbol(AOTCompContext *comp_ctx, const char *symbol, int32 idx)
|
||||||
{
|
{
|
||||||
AOTNativeSymbol *sym = wasm_runtime_malloc(sizeof(AOTNativeSymbol));
|
AOTNativeSymbol *sym = wasm_runtime_malloc(sizeof(AOTNativeSymbol));
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!sym) {
|
if (!sym) {
|
||||||
aot_set_last_error("alloc native symbol failed.");
|
aot_set_last_error("alloc native symbol failed.");
|
||||||
|
@ -3285,7 +3286,11 @@ insert_native_symbol(AOTCompContext *comp_ctx, const char *symbol, int32 idx)
|
||||||
|
|
||||||
memset(sym, 0, sizeof(AOTNativeSymbol));
|
memset(sym, 0, sizeof(AOTNativeSymbol));
|
||||||
bh_assert(strlen(symbol) <= sizeof(sym->symbol));
|
bh_assert(strlen(symbol) <= sizeof(sym->symbol));
|
||||||
snprintf(sym->symbol, sizeof(sym->symbol), "%s", symbol);
|
ret = snprintf(sym->symbol, sizeof(sym->symbol), "%s", symbol);
|
||||||
|
if (ret < 0 || ret + 1 > sizeof(sym->symbol)) {
|
||||||
|
aot_set_last_error_v("symbol name too long: %s", symbol);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
sym->index = idx;
|
sym->index = idx;
|
||||||
|
|
||||||
if (BH_LIST_ERROR == bh_list_insert(&comp_ctx->native_symbols, sym)) {
|
if (BH_LIST_ERROR == bh_list_insert(&comp_ctx->native_symbols, sym)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user