Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasi_random_get: fix memory_getptr failure handling #25

Merged
merged 1 commit into from
Apr 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions libwasi/wasi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2252,10 +2252,10 @@ wasi_random_get(struct exec_context *ctx, struct host_instance *hi,
HOST_FUNC_CONVERT_PARAMS(ft, params);
uint32_t buf = HOST_FUNC_PARAM(ft, params, 0, i32);
uint32_t buflen = HOST_FUNC_PARAM(ft, params, 1, i32);
int ret;
int ret = 0;
void *p;
ret = memory_getptr(ctx, 0, buf, 0, buflen, &p);
if (ret != 0) {
int host_ret = memory_getptr(ctx, 0, buf, 0, buflen, &p);
if (host_ret != 0) {
goto fail;
}
#if defined(__GLIBC__) || defined(__NuttX__)
Expand Down Expand Up @@ -2284,9 +2284,12 @@ wasi_random_get(struct exec_context *ctx, struct host_instance *hi,
ret = 0;
#endif
fail:
HOST_FUNC_RESULT_SET(ft, results, 0, i32, wasi_convert_errno(ret));
if (host_ret == 0) {
HOST_FUNC_RESULT_SET(ft, results, 0, i32,
wasi_convert_errno(ret));
}
HOST_FUNC_FREE_CONVERTED_PARAMS();
return 0;
return host_ret;
}

static int
Expand Down