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

deps: update uvwasi to 0.0.21 #52863

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion deps/uvwasi/include/uvwasi.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern "C" {

#define UVWASI_VERSION_MAJOR 0
#define UVWASI_VERSION_MINOR 0
#define UVWASI_VERSION_PATCH 20
#define UVWASI_VERSION_PATCH 21
#define UVWASI_VERSION_HEX ((UVWASI_VERSION_MAJOR << 16) | \
(UVWASI_VERSION_MINOR << 8) | \
(UVWASI_VERSION_PATCH))
Expand Down
2 changes: 1 addition & 1 deletion deps/uvwasi/src/path_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ static uvwasi_errno_t uvwasi__normalize_relative_path(
normalized. */
uvwasi_errno_t err;
char* combined;
char* normalized;
char* normalized = NULL;
uvwasi_size_t combined_len;
uvwasi_size_t fd_path_len;
uvwasi_size_t norm_len;
Expand Down
43 changes: 37 additions & 6 deletions deps/uvwasi/src/uvwasi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ uvwasi_errno_t uvwasi_fd_pread(uvwasi_t* uvwasi,
offset,
nread);

if (uvwasi == NULL || iovs == NULL || nread == NULL)
if (uvwasi == NULL || (iovs == NULL && iovs_len > 0) || nread == NULL || offset > INT64_MAX)
return UVWASI_EINVAL;

err = uvwasi_fd_table_get(uvwasi->fds,
Expand All @@ -1169,6 +1169,14 @@ uvwasi_errno_t uvwasi_fd_pread(uvwasi_t* uvwasi,
if (err != UVWASI_ESUCCESS)
return err;

// libuv returns EINVAL in this case. To behave consistently with other
// Wasm runtimes, return OK here with a no-op.
if (iovs_len == 0) {
uv_mutex_unlock(&wrap->mutex);
*nread = 0;
return UVWASI_ESUCCESS;
}

err = uvwasi__setup_iovs(uvwasi, &bufs, iovs, iovs_len);
if (err != UVWASI_ESUCCESS) {
uv_mutex_unlock(&wrap->mutex);
Expand Down Expand Up @@ -1282,7 +1290,7 @@ uvwasi_errno_t uvwasi_fd_pwrite(uvwasi_t* uvwasi,
offset,
nwritten);

if (uvwasi == NULL || iovs == NULL || nwritten == NULL)
if (uvwasi == NULL || (iovs == NULL && iovs_len > 0) || nwritten == NULL || offset > INT64_MAX)
return UVWASI_EINVAL;

err = uvwasi_fd_table_get(uvwasi->fds,
Expand All @@ -1293,6 +1301,14 @@ uvwasi_errno_t uvwasi_fd_pwrite(uvwasi_t* uvwasi,
if (err != UVWASI_ESUCCESS)
return err;

// libuv returns EINVAL in this case. To behave consistently with other
// Wasm runtimes, return OK here with a no-op.
if (iovs_len == 0) {
uv_mutex_unlock(&wrap->mutex);
*nwritten = 0;
return UVWASI_ESUCCESS;
}

err = uvwasi__setup_ciovs(uvwasi, &bufs, iovs, iovs_len);
if (err != UVWASI_ESUCCESS) {
uv_mutex_unlock(&wrap->mutex);
Expand Down Expand Up @@ -1332,14 +1348,21 @@ uvwasi_errno_t uvwasi_fd_read(uvwasi_t* uvwasi,
iovs,
iovs_len,
nread);

if (uvwasi == NULL || iovs == NULL || nread == NULL)
if (uvwasi == NULL || (iovs == NULL && iovs_len > 0) || nread == NULL)
return UVWASI_EINVAL;

err = uvwasi_fd_table_get(uvwasi->fds, fd, &wrap, UVWASI_RIGHT_FD_READ, 0);
if (err != UVWASI_ESUCCESS)
return err;

// libuv returns EINVAL in this case. To behave consistently with other
// Wasm runtimes, return OK here with a no-op.
if (iovs_len == 0) {
uv_mutex_unlock(&wrap->mutex);
*nread = 0;
return UVWASI_ESUCCESS;
}

err = uvwasi__setup_iovs(uvwasi, &bufs, iovs, iovs_len);
if (err != UVWASI_ESUCCESS) {
uv_mutex_unlock(&wrap->mutex);
Expand Down Expand Up @@ -1634,13 +1657,21 @@ uvwasi_errno_t uvwasi_fd_write(uvwasi_t* uvwasi,
iovs_len,
nwritten);

if (uvwasi == NULL || iovs == NULL || nwritten == NULL)
if (uvwasi == NULL || (iovs == NULL && iovs_len > 0) || nwritten == NULL)
return UVWASI_EINVAL;

err = uvwasi_fd_table_get(uvwasi->fds, fd, &wrap, UVWASI_RIGHT_FD_WRITE, 0);
if (err != UVWASI_ESUCCESS)
return err;

// libuv returns EINVAL in this case. To behave consistently with other
// Wasm runtimes, return OK here with a no-op.
if (iovs_len == 0) {
uv_mutex_unlock(&wrap->mutex);
*nwritten = 0;
return UVWASI_ESUCCESS;
}

err = uvwasi__setup_ciovs(uvwasi, &bufs, iovs, iovs_len);
if (err != UVWASI_ESUCCESS) {
uv_mutex_unlock(&wrap->mutex);
Expand Down Expand Up @@ -2168,7 +2199,7 @@ uvwasi_errno_t uvwasi_path_readlink(uvwasi_t* uvwasi,

memcpy(buf, req.ptr, len);
buf[len] = '\0';
*bufused = len + 1;
*bufused = len;
uv_fs_req_cleanup(&req);
return UVWASI_ESUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion test/wasi/c/create_symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int main() {

assert(0 == symlink(target, linkpath));
assert(readlink(linkpath, readlink_result, result_size) ==
strlen(target) + 1);
strlen(target));
assert(0 == strcmp(readlink_result, target));

FILE* file = fopen(linkpath, "r");
Expand Down
Binary file modified test/wasi/wasm/create_symlink.wasm
Binary file not shown.
Loading