From 6de85f7ea02f883dfbb301b90fd55f2a3d90b7bd Mon Sep 17 00:00:00 2001 From: cjihrig Date: Wed, 17 Nov 2021 21:59:30 -0500 Subject: [PATCH] deps: update to uvwasi 0.0.12 Notable changes: - Several overflows have been fixed. - The libuv dependency has been updated to v1.42.0. --- deps/uvwasi/include/uvwasi.h | 4 ++-- deps/uvwasi/include/wasi_types.h | 2 +- deps/uvwasi/src/clocks.c | 24 ++++++++++++------------ deps/uvwasi/src/fd_table.c | 2 +- deps/uvwasi/src/fd_table.h | 2 +- deps/uvwasi/src/uvwasi.c | 5 ++++- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/deps/uvwasi/include/uvwasi.h b/deps/uvwasi/include/uvwasi.h index d093a412d6d863..28d38568612607 100644 --- a/deps/uvwasi/include/uvwasi.h +++ b/deps/uvwasi/include/uvwasi.h @@ -10,7 +10,7 @@ extern "C" { #define UVWASI_VERSION_MAJOR 0 #define UVWASI_VERSION_MINOR 0 -#define UVWASI_VERSION_PATCH 11 +#define UVWASI_VERSION_PATCH 12 #define UVWASI_VERSION_HEX ((UVWASI_VERSION_MAJOR << 16) | \ (UVWASI_VERSION_MINOR << 8) | \ (UVWASI_VERSION_PATCH)) @@ -68,7 +68,7 @@ typedef struct uvwasi_options_s { } uvwasi_options_t; /* Embedder API. */ -uvwasi_errno_t uvwasi_init(uvwasi_t* uvwasi, uvwasi_options_t* options); +uvwasi_errno_t uvwasi_init(uvwasi_t* uvwasi, const uvwasi_options_t* options); void uvwasi_destroy(uvwasi_t* uvwasi); void uvwasi_options_init(uvwasi_options_t* options); /* Use int instead of uv_file to avoid needing uv.h */ diff --git a/deps/uvwasi/include/wasi_types.h b/deps/uvwasi/include/wasi_types.h index 57c2dd2f3ce589..35e46a821b69fb 100644 --- a/deps/uvwasi/include/wasi_types.h +++ b/deps/uvwasi/include/wasi_types.h @@ -4,7 +4,7 @@ #include #include -/* API: https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs.md */ +/* API: https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md */ typedef uint32_t uvwasi_size_t; diff --git a/deps/uvwasi/src/clocks.c b/deps/uvwasi/src/clocks.c index b59cbd6bb192c0..8dc5d6557ed2b5 100644 --- a/deps/uvwasi/src/clocks.c +++ b/deps/uvwasi/src/clocks.c @@ -37,12 +37,12 @@ ); \ } \ \ - (time) = (((sys_system.wHour * 3600) + (sys_system.wMinute * 60) + \ - sys_system.wSecond) * NANOS_PER_SEC) + \ - (sys_system.wMilliseconds * 1000000) + \ - (((sys_user.wHour * 3600) + (sys_user.wMinute * 60) + \ - sys_user.wSecond) * NANOS_PER_SEC) + \ - (sys_user.wMilliseconds * 1000000); \ + (time) = (((uvwasi_timestamp_t)(sys_system.wHour * 3600) + \ + (sys_system.wMinute * 60) + sys_system.wSecond) * NANOS_PER_SEC) + \ + ((uvwasi_timestamp_t)(sys_system.wMilliseconds) * 1000000) + \ + (((uvwasi_timestamp_t)(sys_user.wHour * 3600) + \ + (sys_user.wMinute * 60) + sys_user.wSecond) * NANOS_PER_SEC) + \ + ((uvwasi_timestamp_t)(sys_user.wMilliseconds) * 1000000); \ return UVWASI_ESUCCESS; \ } while (0) @@ -52,7 +52,7 @@ struct timespec ts; \ if (0 != clock_gettime((clk), &ts)) \ return uvwasi__translate_uv_error(uv_translate_sys_error(errno)); \ - (time) = (ts.tv_sec * NANOS_PER_SEC) + ts.tv_nsec; \ + (time) = ((uvwasi_timestamp_t)(ts.tv_sec) * NANOS_PER_SEC) + ts.tv_nsec; \ return UVWASI_ESUCCESS; \ } while (0) @@ -62,9 +62,9 @@ struct rusage ru; \ if (0 != getrusage((who), &ru)) \ return uvwasi__translate_uv_error(uv_translate_sys_error(errno)); \ - (time) = (ru.ru_utime.tv_sec * NANOS_PER_SEC) + \ + (time) = ((uvwasi_timestamp_t)(ru.ru_utime.tv_sec) * NANOS_PER_SEC) + \ (ru.ru_utime.tv_usec * 1000) + \ - (ru.ru_stime.tv_sec * NANOS_PER_SEC) + \ + ((uvwasi_timestamp_t)(ru.ru_stime.tv_sec) * NANOS_PER_SEC) + \ (ru.ru_stime.tv_usec * 1000); \ return UVWASI_ESUCCESS; \ } while (0) @@ -83,9 +83,9 @@ &count)) { \ return UVWASI_ENOSYS; \ } \ - (time) = (info.user_time.seconds * NANOS_PER_SEC) + \ + (time) = ((uvwasi_timestamp_t)(info.user_time.seconds) * NANOS_PER_SEC) + \ (info.user_time.microseconds * 1000) + \ - (info.system_time.seconds * NANOS_PER_SEC) + \ + ((uvwasi_timestamp_t)(info.system_time.seconds) * NANOS_PER_SEC) + \ (info.system_time.microseconds * 1000); \ return UVWASI_ESUCCESS; \ } while (0) @@ -109,7 +109,7 @@ if (0 != clock_getres((clk), &ts)) \ (time) = 1000000; \ else \ - (time) = (ts.tv_sec * NANOS_PER_SEC) + ts.tv_nsec; \ + (time) = ((uvwasi_timestamp_t)(ts.tv_sec) * NANOS_PER_SEC) + ts.tv_nsec; \ return UVWASI_ESUCCESS; \ } while (0) diff --git a/deps/uvwasi/src/fd_table.c b/deps/uvwasi/src/fd_table.c index 877faf4ca19cd0..7782f1ee43b420 100644 --- a/deps/uvwasi/src/fd_table.c +++ b/deps/uvwasi/src/fd_table.c @@ -172,7 +172,7 @@ uvwasi_errno_t uvwasi_fd_table_insert(uvwasi_t* uvwasi, uvwasi_errno_t uvwasi_fd_table_init(uvwasi_t* uvwasi, - uvwasi_options_t* options) { + const uvwasi_options_t* options) { struct uvwasi_fd_table_t* table; uvwasi_errno_t err; int r; diff --git a/deps/uvwasi/src/fd_table.h b/deps/uvwasi/src/fd_table.h index 474a0231e03baf..0755c2d17fdec2 100644 --- a/deps/uvwasi/src/fd_table.h +++ b/deps/uvwasi/src/fd_table.h @@ -29,7 +29,7 @@ struct uvwasi_fd_table_t { }; uvwasi_errno_t uvwasi_fd_table_init(struct uvwasi_s* uvwasi, - struct uvwasi_options_s* options); + const struct uvwasi_options_s* options); void uvwasi_fd_table_free(struct uvwasi_s* uvwasi, struct uvwasi_fd_table_t* table); uvwasi_errno_t uvwasi_fd_table_insert(struct uvwasi_s* uvwasi, diff --git a/deps/uvwasi/src/uvwasi.c b/deps/uvwasi/src/uvwasi.c index 0b4b091f9d5a1f..25ce4ab846ef86 100644 --- a/deps/uvwasi/src/uvwasi.c +++ b/deps/uvwasi/src/uvwasi.c @@ -127,6 +127,9 @@ void* uvwasi__malloc(const uvwasi_t* uvwasi, size_t size) { } void uvwasi__free(const uvwasi_t* uvwasi, void* ptr) { + if (ptr == NULL) + return; + uvwasi->allocator->free(ptr, uvwasi->allocator->mem_user_data); } @@ -229,7 +232,7 @@ static uvwasi_errno_t uvwasi__setup_ciovs(const uvwasi_t* uvwasi, } -uvwasi_errno_t uvwasi_init(uvwasi_t* uvwasi, uvwasi_options_t* options) { +uvwasi_errno_t uvwasi_init(uvwasi_t* uvwasi, const uvwasi_options_t* options) { uv_fs_t realpath_req; uv_fs_t open_req; uvwasi_errno_t err;