From ba9a5e907a705dbe2229a4db29d0440925eb75a2 Mon Sep 17 00:00:00 2001 From: Julian Scott Date: Tue, 2 Jun 2026 12:50:32 +0200 Subject: [PATCH 1/2] fix(sock_recv/send): allow size of 0 --- core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c b/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c index 5ab189e71d..59c848e6b6 100644 --- a/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c +++ b/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c @@ -2009,10 +2009,6 @@ allocate_iovec_app_buffer(wasm_module_inst_t module_inst, uint32 i; uint8 *buf_begin = NULL; - if (data_len == 0) { - return __WASI_EINVAL; - } - total_size = sizeof(iovec_app_t) * (uint64)data_len; if (total_size >= UINT32_MAX || !validate_native_addr((void *)data, total_size)) @@ -2022,12 +2018,8 @@ allocate_iovec_app_buffer(wasm_module_inst_t module_inst, total_size += data->buf_len; } - if (total_size == 0) { - return __WASI_EINVAL; - } - if (total_size >= UINT32_MAX - || !(buf_begin = wasm_runtime_malloc((uint32)total_size))) { + || !(buf_begin = wasm_runtime_malloc(total_size ? (uint32)total_size : 1))) { return __WASI_ENOMEM; } From cb7e89c5bdbce7be0dfb2864770bbe547026a1a6 Mon Sep 17 00:00:00 2001 From: Julian Scott Date: Tue, 2 Jun 2026 12:53:40 +0200 Subject: [PATCH 2/2] chore: format --- core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c b/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c index 59c848e6b6..d577dfb5d6 100644 --- a/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c +++ b/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c @@ -2019,7 +2019,8 @@ allocate_iovec_app_buffer(wasm_module_inst_t module_inst, } if (total_size >= UINT32_MAX - || !(buf_begin = wasm_runtime_malloc(total_size ? (uint32)total_size : 1))) { + || !(buf_begin = + wasm_runtime_malloc(total_size ? (uint32)total_size : 1))) { return __WASI_ENOMEM; }