deps: update uvwasi to 0.0.21

PR-URL: https://github.com/nodejs/node/pull/52863
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Node.js GitHub Bot 2024-05-05 00:26:09 +00:00 committed by Michael Dawson
parent a833c9e0be
commit 58a5b3042c
5 changed files with 40 additions and 9 deletions

View File

@ -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))

View File

@ -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;

View File

@ -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,
@ -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);
@ -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,
@ -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);
@ -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);
@ -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);
@ -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;
}

View File

@ -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");

Binary file not shown.