|
|
@@ -132,9 +132,9 @@ wasi_args_get(wasm_exec_env_t exec_env, uint32 *argv_offsets, char *argv_buf)
|
|
|
|
|
|
total_size = sizeof(int32) * ((uint64)argc + 1);
|
|
|
if (total_size >= UINT32_MAX
|
|
|
- || !validate_native_addr(argv_offsets, (uint32)total_size)
|
|
|
+ || !validate_native_addr(argv_offsets, total_size)
|
|
|
|| argv_buf_size >= UINT32_MAX
|
|
|
- || !validate_native_addr(argv_buf, (uint32)argv_buf_size))
|
|
|
+ || !validate_native_addr(argv_buf, (uint64)argv_buf_size))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
total_size = sizeof(char *) * ((uint64)argc + 1);
|
|
|
@@ -149,7 +149,7 @@ wasi_args_get(wasm_exec_env_t exec_env, uint32 *argv_offsets, char *argv_buf)
|
|
|
}
|
|
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
- argv_offsets[i] = addr_native_to_app(argv[i]);
|
|
|
+ argv_offsets[i] = (uint32)addr_native_to_app(argv[i]);
|
|
|
|
|
|
wasm_runtime_free(argv);
|
|
|
return 0;
|
|
|
@@ -168,8 +168,8 @@ wasi_args_sizes_get(wasm_exec_env_t exec_env, uint32 *argc_app,
|
|
|
if (!wasi_ctx)
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
- if (!validate_native_addr(argc_app, sizeof(uint32))
|
|
|
- || !validate_native_addr(argv_buf_size_app, sizeof(uint32)))
|
|
|
+ if (!validate_native_addr(argc_app, (uint64)sizeof(uint32))
|
|
|
+ || !validate_native_addr(argv_buf_size_app, (uint64)sizeof(uint32)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
argv_environ = wasi_ctx->argv_environ;
|
|
|
@@ -190,7 +190,7 @@ wasi_clock_res_get(wasm_exec_env_t exec_env,
|
|
|
{
|
|
|
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
|
|
|
|
|
- if (!validate_native_addr(resolution, sizeof(wasi_timestamp_t)))
|
|
|
+ if (!validate_native_addr(resolution, (uint64)sizeof(wasi_timestamp_t)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
return os_clock_res_get(clock_id, resolution);
|
|
|
@@ -204,7 +204,7 @@ wasi_clock_time_get(wasm_exec_env_t exec_env,
|
|
|
{
|
|
|
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
|
|
|
|
|
- if (!validate_native_addr(time, sizeof(wasi_timestamp_t)))
|
|
|
+ if (!validate_native_addr(time, (uint64)sizeof(wasi_timestamp_t)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
return os_clock_time_get(clock_id, precision, time);
|
|
|
@@ -233,9 +233,9 @@ wasi_environ_get(wasm_exec_env_t exec_env, uint32 *environ_offsets,
|
|
|
|
|
|
total_size = sizeof(int32) * ((uint64)environ_count + 1);
|
|
|
if (total_size >= UINT32_MAX
|
|
|
- || !validate_native_addr(environ_offsets, (uint32)total_size)
|
|
|
+ || !validate_native_addr(environ_offsets, total_size)
|
|
|
|| environ_buf_size >= UINT32_MAX
|
|
|
- || !validate_native_addr(environ_buf, (uint32)environ_buf_size))
|
|
|
+ || !validate_native_addr(environ_buf, (uint64)environ_buf_size))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
total_size = sizeof(char *) * (((uint64)environ_count + 1));
|
|
|
@@ -251,7 +251,7 @@ wasi_environ_get(wasm_exec_env_t exec_env, uint32 *environ_offsets,
|
|
|
}
|
|
|
|
|
|
for (i = 0; i < environ_count; i++)
|
|
|
- environ_offsets[i] = addr_native_to_app(environs[i]);
|
|
|
+ environ_offsets[i] = (uint32)addr_native_to_app(environs[i]);
|
|
|
|
|
|
wasm_runtime_free(environs);
|
|
|
return 0;
|
|
|
@@ -271,8 +271,8 @@ wasi_environ_sizes_get(wasm_exec_env_t exec_env, uint32 *environ_count_app,
|
|
|
if (!wasi_ctx)
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
- if (!validate_native_addr(environ_count_app, sizeof(uint32))
|
|
|
- || !validate_native_addr(environ_buf_size_app, sizeof(uint32)))
|
|
|
+ if (!validate_native_addr(environ_count_app, (uint64)sizeof(uint32))
|
|
|
+ || !validate_native_addr(environ_buf_size_app, (uint64)sizeof(uint32)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
err = wasmtime_ssp_environ_sizes_get(argv_environ, &environ_count,
|
|
|
@@ -299,7 +299,7 @@ wasi_fd_prestat_get(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
- if (!validate_native_addr(prestat_app, sizeof(wasi_prestat_app_t)))
|
|
|
+ if (!validate_native_addr(prestat_app, (uint64)sizeof(wasi_prestat_app_t)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
err = wasmtime_ssp_fd_prestat_get(prestats, fd, &prestat);
|
|
|
@@ -369,9 +369,9 @@ wasi_fd_pread(wasm_exec_env_t exec_env, wasi_fd_t fd, iovec_app_t *iovec_app,
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
total_size = sizeof(iovec_app_t) * (uint64)iovs_len;
|
|
|
- if (!validate_native_addr(nread_app, (uint32)sizeof(uint32))
|
|
|
+ if (!validate_native_addr(nread_app, (uint64)sizeof(uint32))
|
|
|
|| total_size >= UINT32_MAX
|
|
|
- || !validate_native_addr(iovec_app, (uint32)total_size))
|
|
|
+ || !validate_native_addr(iovec_app, total_size))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
total_size = sizeof(wasi_iovec_t) * (uint64)iovs_len;
|
|
|
@@ -382,11 +382,12 @@ wasi_fd_pread(wasm_exec_env_t exec_env, wasi_fd_t fd, iovec_app_t *iovec_app,
|
|
|
iovec = iovec_begin;
|
|
|
|
|
|
for (i = 0; i < iovs_len; i++, iovec_app++, iovec++) {
|
|
|
- if (!validate_app_addr(iovec_app->buf_offset, iovec_app->buf_len)) {
|
|
|
+ if (!validate_app_addr((uint64)iovec_app->buf_offset,
|
|
|
+ (uint64)iovec_app->buf_len)) {
|
|
|
err = (wasi_errno_t)-1;
|
|
|
goto fail;
|
|
|
}
|
|
|
- iovec->buf = (void *)addr_app_to_native(iovec_app->buf_offset);
|
|
|
+ iovec->buf = (void *)addr_app_to_native((uint64)iovec_app->buf_offset);
|
|
|
iovec->buf_len = iovec_app->buf_len;
|
|
|
}
|
|
|
|
|
|
@@ -423,9 +424,9 @@ wasi_fd_pwrite(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
total_size = sizeof(iovec_app_t) * (uint64)iovs_len;
|
|
|
- if (!validate_native_addr(nwritten_app, (uint32)sizeof(uint32))
|
|
|
+ if (!validate_native_addr(nwritten_app, (uint64)sizeof(uint32))
|
|
|
|| total_size >= UINT32_MAX
|
|
|
- || !validate_native_addr((void *)iovec_app, (uint32)total_size))
|
|
|
+ || !validate_native_addr((void *)iovec_app, total_size))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
total_size = sizeof(wasi_ciovec_t) * (uint64)iovs_len;
|
|
|
@@ -436,11 +437,12 @@ wasi_fd_pwrite(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
ciovec = ciovec_begin;
|
|
|
|
|
|
for (i = 0; i < iovs_len; i++, iovec_app++, ciovec++) {
|
|
|
- if (!validate_app_addr(iovec_app->buf_offset, iovec_app->buf_len)) {
|
|
|
+ if (!validate_app_addr((uint64)iovec_app->buf_offset,
|
|
|
+ (uint64)iovec_app->buf_len)) {
|
|
|
err = (wasi_errno_t)-1;
|
|
|
goto fail;
|
|
|
}
|
|
|
- ciovec->buf = (char *)addr_app_to_native(iovec_app->buf_offset);
|
|
|
+ ciovec->buf = (char *)addr_app_to_native((uint64)iovec_app->buf_offset);
|
|
|
ciovec->buf_len = iovec_app->buf_len;
|
|
|
}
|
|
|
|
|
|
@@ -476,9 +478,9 @@ wasi_fd_read(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
total_size = sizeof(iovec_app_t) * (uint64)iovs_len;
|
|
|
- if (!validate_native_addr(nread_app, (uint32)sizeof(uint32))
|
|
|
+ if (!validate_native_addr(nread_app, (uint64)sizeof(uint32))
|
|
|
|| total_size >= UINT32_MAX
|
|
|
- || !validate_native_addr((void *)iovec_app, (uint32)total_size))
|
|
|
+ || !validate_native_addr((void *)iovec_app, total_size))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
total_size = sizeof(wasi_iovec_t) * (uint64)iovs_len;
|
|
|
@@ -489,11 +491,12 @@ wasi_fd_read(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
iovec = iovec_begin;
|
|
|
|
|
|
for (i = 0; i < iovs_len; i++, iovec_app++, iovec++) {
|
|
|
- if (!validate_app_addr(iovec_app->buf_offset, iovec_app->buf_len)) {
|
|
|
+ if (!validate_app_addr((uint64)iovec_app->buf_offset,
|
|
|
+ (uint64)iovec_app->buf_len)) {
|
|
|
err = (wasi_errno_t)-1;
|
|
|
goto fail;
|
|
|
}
|
|
|
- iovec->buf = (void *)addr_app_to_native(iovec_app->buf_offset);
|
|
|
+ iovec->buf = (void *)addr_app_to_native((uint64)iovec_app->buf_offset);
|
|
|
iovec->buf_len = iovec_app->buf_len;
|
|
|
}
|
|
|
|
|
|
@@ -537,7 +540,7 @@ wasi_fd_seek(wasm_exec_env_t exec_env, wasi_fd_t fd, wasi_filedelta_t offset,
|
|
|
if (!wasi_ctx)
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
- if (!validate_native_addr(newoffset, sizeof(wasi_filesize_t)))
|
|
|
+ if (!validate_native_addr(newoffset, (uint64)sizeof(wasi_filesize_t)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
return wasmtime_ssp_fd_seek(exec_env, curfds, fd, offset, whence,
|
|
|
@@ -554,7 +557,7 @@ wasi_fd_tell(wasm_exec_env_t exec_env, wasi_fd_t fd, wasi_filesize_t *newoffset)
|
|
|
if (!wasi_ctx)
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
- if (!validate_native_addr(newoffset, sizeof(wasi_filesize_t)))
|
|
|
+ if (!validate_native_addr(newoffset, (uint64)sizeof(wasi_filesize_t)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
return wasmtime_ssp_fd_tell(exec_env, curfds, fd, newoffset);
|
|
|
@@ -573,7 +576,7 @@ wasi_fd_fdstat_get(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
- if (!validate_native_addr(fdstat_app, sizeof(wasi_fdstat_t)))
|
|
|
+ if (!validate_native_addr(fdstat_app, (uint64)sizeof(wasi_fdstat_t)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
err = wasmtime_ssp_fd_fdstat_get(exec_env, curfds, fd, &fdstat);
|
|
|
@@ -645,9 +648,9 @@ wasi_fd_write(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
total_size = sizeof(iovec_app_t) * (uint64)iovs_len;
|
|
|
- if (!validate_native_addr(nwritten_app, (uint32)sizeof(uint32))
|
|
|
+ if (!validate_native_addr(nwritten_app, (uint64)sizeof(uint32))
|
|
|
|| total_size >= UINT32_MAX
|
|
|
- || !validate_native_addr((void *)iovec_app, (uint32)total_size))
|
|
|
+ || !validate_native_addr((void *)iovec_app, total_size))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
total_size = sizeof(wasi_ciovec_t) * (uint64)iovs_len;
|
|
|
@@ -658,11 +661,12 @@ wasi_fd_write(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
ciovec = ciovec_begin;
|
|
|
|
|
|
for (i = 0; i < iovs_len; i++, iovec_app++, ciovec++) {
|
|
|
- if (!validate_app_addr(iovec_app->buf_offset, iovec_app->buf_len)) {
|
|
|
+ if (!validate_app_addr((uint64)iovec_app->buf_offset,
|
|
|
+ (uint64)iovec_app->buf_len)) {
|
|
|
err = (wasi_errno_t)-1;
|
|
|
goto fail;
|
|
|
}
|
|
|
- ciovec->buf = (char *)addr_app_to_native(iovec_app->buf_offset);
|
|
|
+ ciovec->buf = (char *)addr_app_to_native((uint64)iovec_app->buf_offset);
|
|
|
ciovec->buf_len = iovec_app->buf_len;
|
|
|
}
|
|
|
|
|
|
@@ -759,7 +763,7 @@ wasi_path_open(wasm_exec_env_t exec_env, wasi_fd_t dirfd,
|
|
|
if (!wasi_ctx)
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
- if (!validate_native_addr(fd_app, sizeof(wasi_fd_t)))
|
|
|
+ if (!validate_native_addr(fd_app, (uint64)sizeof(wasi_fd_t)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
err = wasmtime_ssp_path_open(exec_env, curfds, dirfd, dirflags, path,
|
|
|
@@ -783,7 +787,7 @@ wasi_fd_readdir(wasm_exec_env_t exec_env, wasi_fd_t fd, void *buf,
|
|
|
if (!wasi_ctx)
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
- if (!validate_native_addr(bufused_app, sizeof(uint32)))
|
|
|
+ if (!validate_native_addr(bufused_app, (uint64)sizeof(uint32)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
err = wasmtime_ssp_fd_readdir(exec_env, curfds, fd, buf, buf_len, cookie,
|
|
|
@@ -809,7 +813,7 @@ wasi_path_readlink(wasm_exec_env_t exec_env, wasi_fd_t fd, const char *path,
|
|
|
if (!wasi_ctx)
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
- if (!validate_native_addr(bufused_app, sizeof(uint32)))
|
|
|
+ if (!validate_native_addr(bufused_app, (uint64)sizeof(uint32)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
err = wasmtime_ssp_path_readlink(exec_env, curfds, fd, path, path_len, buf,
|
|
|
@@ -849,7 +853,7 @@ wasi_fd_filestat_get(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
- if (!validate_native_addr(filestat, sizeof(wasi_filestat_t)))
|
|
|
+ if (!validate_native_addr(filestat, (uint64)sizeof(wasi_filestat_t)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
return wasmtime_ssp_fd_filestat_get(exec_env, curfds, fd, filestat);
|
|
|
@@ -897,7 +901,7 @@ wasi_path_filestat_get(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
- if (!validate_native_addr(filestat, sizeof(wasi_filestat_t)))
|
|
|
+ if (!validate_native_addr(filestat, (uint64)sizeof(wasi_filestat_t)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
return wasmtime_ssp_path_filestat_get(exec_env, curfds, fd, flags, path,
|
|
|
@@ -1083,9 +1087,9 @@ wasi_poll_oneoff(wasm_exec_env_t exec_env, const wasi_subscription_t *in,
|
|
|
if (!wasi_ctx)
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
- if (!validate_native_addr((void *)in, sizeof(wasi_subscription_t))
|
|
|
- || !validate_native_addr(out, sizeof(wasi_event_t))
|
|
|
- || !validate_native_addr(nevents_app, sizeof(uint32)))
|
|
|
+ if (!validate_native_addr((void *)in, (uint64)sizeof(wasi_subscription_t))
|
|
|
+ || !validate_native_addr(out, (uint64)sizeof(wasi_event_t))
|
|
|
+ || !validate_native_addr(nevents_app, (uint64)sizeof(uint32)))
|
|
|
return (wasi_errno_t)-1;
|
|
|
|
|
|
#if WASM_ENABLE_THREAD_MGR == 0
|
|
|
@@ -1160,7 +1164,7 @@ wasi_sock_addr_local(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(addr, sizeof(__wasi_addr_t)))
|
|
|
+ if (!validate_native_addr(addr, (uint64)sizeof(__wasi_addr_t)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1179,7 +1183,7 @@ wasi_sock_addr_remote(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(addr, sizeof(__wasi_addr_t)))
|
|
|
+ if (!validate_native_addr(addr, (uint64)sizeof(__wasi_addr_t)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1264,7 +1268,7 @@ wasi_sock_get_broadcast(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(is_enabled, sizeof(bool)))
|
|
|
+ if (!validate_native_addr(is_enabled, (uint64)sizeof(bool)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1283,7 +1287,7 @@ wasi_sock_get_keep_alive(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(is_enabled, sizeof(bool)))
|
|
|
+ if (!validate_native_addr(is_enabled, (uint64)sizeof(bool)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1302,8 +1306,8 @@ wasi_sock_get_linger(wasm_exec_env_t exec_env, wasi_fd_t fd, bool *is_enabled,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(is_enabled, sizeof(bool))
|
|
|
- || !validate_native_addr(linger_s, sizeof(int)))
|
|
|
+ if (!validate_native_addr(is_enabled, (uint64)sizeof(bool))
|
|
|
+ || !validate_native_addr(linger_s, (uint64)sizeof(int)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1323,7 +1327,7 @@ wasi_sock_get_recv_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(size, sizeof(wasi_size_t)))
|
|
|
+ if (!validate_native_addr(size, (uint64)sizeof(wasi_size_t)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1342,7 +1346,7 @@ wasi_sock_get_recv_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(timeout_us, sizeof(uint64_t)))
|
|
|
+ if (!validate_native_addr(timeout_us, (uint64)sizeof(uint64_t)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1361,7 +1365,7 @@ wasi_sock_get_reuse_addr(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(is_enabled, sizeof(bool)))
|
|
|
+ if (!validate_native_addr(is_enabled, (uint64)sizeof(bool)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1380,7 +1384,7 @@ wasi_sock_get_reuse_port(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(is_enabled, sizeof(bool)))
|
|
|
+ if (!validate_native_addr(is_enabled, (uint64)sizeof(bool)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1399,7 +1403,7 @@ wasi_sock_get_send_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(size, sizeof(__wasi_size_t)))
|
|
|
+ if (!validate_native_addr(size, (uint64)sizeof(__wasi_size_t)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1418,7 +1422,7 @@ wasi_sock_get_send_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(timeout_us, sizeof(uint64_t)))
|
|
|
+ if (!validate_native_addr(timeout_us, (uint64)sizeof(uint64_t)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1437,7 +1441,7 @@ wasi_sock_get_tcp_fastopen_connect(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(is_enabled, sizeof(bool)))
|
|
|
+ if (!validate_native_addr(is_enabled, (uint64)sizeof(bool)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1457,7 +1461,7 @@ wasi_sock_get_tcp_no_delay(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(is_enabled, sizeof(bool)))
|
|
|
+ if (!validate_native_addr(is_enabled, (uint64)sizeof(bool)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1476,7 +1480,7 @@ wasi_sock_get_tcp_quick_ack(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(is_enabled, sizeof(bool)))
|
|
|
+ if (!validate_native_addr(is_enabled, (uint64)sizeof(bool)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1496,7 +1500,7 @@ wasi_sock_get_tcp_keep_idle(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(time_s, sizeof(uint32_t)))
|
|
|
+ if (!validate_native_addr(time_s, (uint64)sizeof(uint32_t)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1515,7 +1519,7 @@ wasi_sock_get_tcp_keep_intvl(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(time_s, sizeof(uint32_t)))
|
|
|
+ if (!validate_native_addr(time_s, (uint64)sizeof(uint32_t)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1534,7 +1538,7 @@ wasi_sock_get_ip_multicast_loop(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(is_enabled, sizeof(bool)))
|
|
|
+ if (!validate_native_addr(is_enabled, (uint64)sizeof(bool)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1553,7 +1557,7 @@ wasi_sock_get_ip_ttl(wasm_exec_env_t exec_env, wasi_fd_t fd, uint8_t *ttl_s)
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(ttl_s, sizeof(uint8_t)))
|
|
|
+ if (!validate_native_addr(ttl_s, (uint64)sizeof(uint8_t)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1572,7 +1576,7 @@ wasi_sock_get_ip_multicast_ttl(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(ttl_s, sizeof(uint8_t)))
|
|
|
+ if (!validate_native_addr(ttl_s, (uint64)sizeof(uint8_t)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1591,7 +1595,7 @@ wasi_sock_get_ipv6_only(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(is_enabled, sizeof(bool)))
|
|
|
+ if (!validate_native_addr(is_enabled, (uint64)sizeof(bool)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1884,7 +1888,7 @@ wasi_sock_set_ip_add_membership(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(imr_multiaddr, sizeof(__wasi_addr_ip_t)))
|
|
|
+ if (!validate_native_addr(imr_multiaddr, (uint64)sizeof(__wasi_addr_ip_t)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1905,7 +1909,7 @@ wasi_sock_set_ip_drop_membership(wasm_exec_env_t exec_env, wasi_fd_t fd,
|
|
|
if (!wasi_ctx)
|
|
|
return __WASI_EACCES;
|
|
|
|
|
|
- if (!validate_native_addr(imr_multiaddr, sizeof(__wasi_addr_ip_t)))
|
|
|
+ if (!validate_native_addr(imr_multiaddr, (uint64)sizeof(__wasi_addr_ip_t)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
curfds = wasi_ctx_get_curfds(wasi_ctx);
|
|
|
@@ -1975,7 +1979,7 @@ allocate_iovec_app_buffer(wasm_module_inst_t module_inst,
|
|
|
|
|
|
total_size = sizeof(iovec_app_t) * (uint64)data_len;
|
|
|
if (total_size >= UINT32_MAX
|
|
|
- || !validate_native_addr((void *)data, (uint32)total_size))
|
|
|
+ || !validate_native_addr((void *)data, total_size))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
for (total_size = 0, i = 0; i < data_len; i++, data++) {
|
|
|
@@ -2013,7 +2017,8 @@ copy_buffer_to_iovec_app(wasm_module_inst_t module_inst, uint8 *buf_begin,
|
|
|
for (i = 0; i < data_len; data++, i++) {
|
|
|
char *native_addr;
|
|
|
|
|
|
- if (!validate_app_addr(data->buf_offset, data->buf_len)) {
|
|
|
+ if (!validate_app_addr((uint64)data->buf_offset,
|
|
|
+ (uint64)data->buf_len)) {
|
|
|
return __WASI_EINVAL;
|
|
|
}
|
|
|
|
|
|
@@ -2032,7 +2037,7 @@ copy_buffer_to_iovec_app(wasm_module_inst_t module_inst, uint8 *buf_begin,
|
|
|
*/
|
|
|
size_to_copy_into_iovec = min_uint32(data->buf_len, size_to_copy);
|
|
|
|
|
|
- native_addr = (void *)addr_app_to_native(data->buf_offset);
|
|
|
+ native_addr = (void *)addr_app_to_native((uint64)data->buf_offset);
|
|
|
bh_memcpy_s(native_addr, size_to_copy_into_iovec, buf,
|
|
|
size_to_copy_into_iovec);
|
|
|
buf += size_to_copy_into_iovec;
|
|
|
@@ -2064,7 +2069,7 @@ wasi_sock_recv_from(wasm_exec_env_t exec_env, wasi_fd_t sock,
|
|
|
return __WASI_EINVAL;
|
|
|
}
|
|
|
|
|
|
- if (!validate_native_addr(ro_data_len, (uint32)sizeof(uint32)))
|
|
|
+ if (!validate_native_addr(ro_data_len, (uint64)sizeof(uint32)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
err = allocate_iovec_app_buffer(module_inst, ri_data, ri_data_len,
|
|
|
@@ -2103,7 +2108,7 @@ wasi_sock_recv(wasm_exec_env_t exec_env, wasi_fd_t sock, iovec_app_t *ri_data,
|
|
|
__wasi_addr_t src_addr;
|
|
|
wasi_errno_t error;
|
|
|
|
|
|
- if (!validate_native_addr(ro_flags, (uint32)sizeof(wasi_roflags_t)))
|
|
|
+ if (!validate_native_addr(ro_flags, (uint64)sizeof(wasi_roflags_t)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
error = wasi_sock_recv_from(exec_env, sock, ri_data, ri_data_len, ri_flags,
|
|
|
@@ -2134,12 +2139,13 @@ convert_iovec_app_to_buffer(wasm_module_inst_t module_inst,
|
|
|
for (i = 0; i < si_data_len; i++, si_data++) {
|
|
|
char *native_addr;
|
|
|
|
|
|
- if (!validate_app_addr(si_data->buf_offset, si_data->buf_len)) {
|
|
|
+ if (!validate_app_addr((uint64)si_data->buf_offset,
|
|
|
+ (uint64)si_data->buf_len)) {
|
|
|
wasm_runtime_free(*buf_ptr);
|
|
|
return __WASI_EINVAL;
|
|
|
}
|
|
|
|
|
|
- native_addr = (char *)addr_app_to_native(si_data->buf_offset);
|
|
|
+ native_addr = (char *)addr_app_to_native((uint64)si_data->buf_offset);
|
|
|
bh_memcpy_s(buf, si_data->buf_len, native_addr, si_data->buf_len);
|
|
|
buf += si_data->buf_len;
|
|
|
}
|
|
|
@@ -2168,7 +2174,7 @@ wasi_sock_send(wasm_exec_env_t exec_env, wasi_fd_t sock,
|
|
|
return __WASI_EINVAL;
|
|
|
}
|
|
|
|
|
|
- if (!validate_native_addr(so_data_len, sizeof(uint32)))
|
|
|
+ if (!validate_native_addr(so_data_len, (uint64)sizeof(uint32)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
err = convert_iovec_app_to_buffer(module_inst, si_data, si_data_len, &buf,
|
|
|
@@ -2209,7 +2215,7 @@ wasi_sock_send_to(wasm_exec_env_t exec_env, wasi_fd_t sock,
|
|
|
return __WASI_EINVAL;
|
|
|
}
|
|
|
|
|
|
- if (!validate_native_addr(so_data_len, sizeof(uint32)))
|
|
|
+ if (!validate_native_addr(so_data_len, (uint64)sizeof(uint32)))
|
|
|
return __WASI_EINVAL;
|
|
|
|
|
|
err = convert_iovec_app_to_buffer(module_inst, si_data, si_data_len, &buf,
|