fix(runtime): the wasm host serves the luau blob's remaining wasi imports (#14320) 9ba30dbad9 * fix(runtime): the wasm host serves the Luau blob's environ and fd_close wasi imports * fix(runtime): environ_sizes_get checks both output pointers before writing Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
diff --git a/.rive_head b/.rive_head index 3efaad0..d8a5f5c 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -4c824e6f05d23dfc0c9d22d7496c33a782ccc366 +9ba30dbad9fc35646bff0b61f6a7e47f87091ab6
diff --git a/src/wasm/wasm_scripting_vm.cpp b/src/wasm/wasm_scripting_vm.cpp index 6a7ceb3..7d920a1 100644 --- a/src/wasm/wasm_scripting_vm.cpp +++ b/src/wasm/wasm_scripting_vm.cpp
@@ -1034,9 +1034,34 @@ return 70; // WASI ESPIPE } +// The blob's libc asks for the environment at start and closes its streams +// at exit; there is no environment and the streams are the log. +uint32_t environSizesGet(wasm_exec_env_t env, uint32_t* count, uint32_t* size) +{ + wasm_module_inst_t inst = wasm_runtime_get_module_inst(env); + if (!wasm_runtime_validate_native_addr(inst, count, 4) || + !wasm_runtime_validate_native_addr(inst, size, 4)) + { + return 21; // WASI EFAULT + } + *count = 0; + *size = 0; + return 0; +} + +uint32_t environGet(wasm_exec_env_t env, uint32_t* environ, char* buffer) +{ + return 0; +} + +uint32_t fdClose(wasm_exec_env_t env, uint32_t fd) { return 0; } + NativeSymbol kWasiNatives[] = { {"fd_write", (void*)fdWrite, "(i*i*)i", nullptr}, {"fd_seek", (void*)fdSeek, "(iiiii)i", nullptr}, + {"environ_sizes_get", (void*)environSizesGet, "(**)i", nullptr}, + {"environ_get", (void*)environGet, "(**)i", nullptr}, + {"fd_close", (void*)fdClose, "(i)i", nullptr}, }; // --- rive_path/paint/renderer_v1: handle-backed render objects --------------