diff --git a/applications/wasm_apps b/applications/wasm_apps index d1c345f..1ae4a32 160000 --- a/applications/wasm_apps +++ b/applications/wasm_apps @@ -1 +1 @@ -Subproject commit d1c345ffacf11a9478ee5ec0772fe5104bc752f5 +Subproject commit 1ae4a32dea4abdb48db079c725862c649fc9b600 diff --git a/libsledge/src/wasi_snapshot_preview1.c b/libsledge/src/wasi_snapshot_preview1.c index edf7172..4e70ecc 100644 --- a/libsledge/src/wasi_snapshot_preview1.c +++ b/libsledge/src/wasi_snapshot_preview1.c @@ -6,7 +6,7 @@ uint32_t wasi_snapshot_preview1_args_get(__wasi_size_t argv_retoffset, __wasi_size_t argv_buf_retoffset) { - return sledge_abi__wasi_snapshot_preview1_args_get(argv_buf_retoffset, argv_buf_retoffset); + return sledge_abi__wasi_snapshot_preview1_args_get(argv_retoffset, argv_buf_retoffset); } uint32_t diff --git a/runtime/src/current_sandbox.c b/runtime/src/current_sandbox.c index 3ed5ffa..04922a0 100644 --- a/runtime/src/current_sandbox.c +++ b/runtime/src/current_sandbox.c @@ -19,8 +19,8 @@ thread_local struct sandbox *worker_thread_current_sandbox = NULL; // TODO: Propagate arguments from *.json spec file -const int dummy_argc = 1; -const char *dummy_argv[] = { "Test" }; +const int dummy_argc = 4; +const char *dummy_argv[] = { "/test/test/test", "foo", "bar", "baz" }; /** * @brief Switches from an executing sandbox to the worker thread base context diff --git a/runtime/src/libc/wasi_impl_serverless.c b/runtime/src/libc/wasi_impl_serverless.c index 8799f10..f164326 100644 --- a/runtime/src/libc/wasi_impl_serverless.c +++ b/runtime/src/libc/wasi_impl_serverless.c @@ -326,8 +326,8 @@ wasi_fromerrno(int errno_) * Callers of this syscall only provide the base address of the two buffers because the WASI specification * assumes that the caller first called args_sizes_get and sized the buffers appropriately. * - * @param argv_retptr - * @param argv_buf_retptr + * @param argv - temp argv to store host pointers into sandbox linear memory + * @param argv_buf_retptr - host pointer to the start of the argv buffer in linear memory * @return __WASI_ERRNO_SUCCESS or WASI_EINVAL */ __wasi_errno_t @@ -338,8 +338,8 @@ wasi_snapshot_preview1_backing_args_get(wasi_context_t *context, char **argv, ch if (context->argc > 0) memcpy(argv_buf, context->argv_buf, context->argv_buf_size); for (__wasi_size_t i = 0; i < context->argc; i++) { - __wasi_size_t offset = context->argv[i] - context->argv_buf; - argv[i] = &argv_buf[context->argv[i] - context->argv_buf]; + size_t offset = context->argv[i] - context->argv_buf; + argv[i] = &argv_buf[offset]; } @@ -360,10 +360,6 @@ wasi_snapshot_preview1_backing_args_sizes_get(wasi_context_t *context, __wasi_si { if (context == NULL || argc_retptr == NULL || argv_buf_len_retptr == NULL) return __WASI_ERRNO_INVAL; - // TODO: Delete after refactoring args logic - // fprintf(stderr, "argc: %d\n", wasi_context->argc); - // fprintf(stderr, "argv_buf_size: %d\n", wasi_context->argv_buf_size); - *argc_retptr = context->argc; *argv_buf_len_retptr = context->argv_buf_size; return __WASI_ERRNO_SUCCESS;