Skip to content

Commit e073da0

Browse files
cjihrigtargos
authored andcommitted
deps: update to uvwasi 0.0.8
This release focuses on improving the robustness of the path resolution and sandboxing, including adding support for relative preopen paths. PR-URL: #33078 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 7f845e6 commit e073da0

File tree

9 files changed

+546
-337
lines changed

9 files changed

+546
-337
lines changed

deps/uvwasi/include/fd_table.h

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ struct uvwasi_fd_wrap_t {
1313
uv_file fd;
1414
char* path;
1515
char* real_path;
16+
char* normalized_path;
1617
uvwasi_filetype_t type;
1718
uvwasi_rights_t rights_base;
1819
uvwasi_rights_t rights_inheriting;

deps/uvwasi/include/uvwasi.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern "C" {
1111

1212
#define UVWASI_VERSION_MAJOR 0
1313
#define UVWASI_VERSION_MINOR 0
14-
#define UVWASI_VERSION_PATCH 6
14+
#define UVWASI_VERSION_PATCH 8
1515
#define UVWASI_VERSION_HEX ((UVWASI_VERSION_MAJOR << 16) | \
1616
(UVWASI_VERSION_MINOR << 8) | \
1717
(UVWASI_VERSION_PATCH))
@@ -66,7 +66,7 @@ typedef struct uvwasi_options_s {
6666
const uvwasi_mem_t* allocator;
6767
} uvwasi_options_t;
6868

69-
// Embedder API.
69+
/* Embedder API. */
7070
uvwasi_errno_t uvwasi_init(uvwasi_t* uvwasi, uvwasi_options_t* options);
7171
void uvwasi_destroy(uvwasi_t* uvwasi);
7272
uvwasi_errno_t uvwasi_embedder_remap_fd(uvwasi_t* uvwasi,
@@ -75,7 +75,7 @@ uvwasi_errno_t uvwasi_embedder_remap_fd(uvwasi_t* uvwasi,
7575
const char* uvwasi_embedder_err_code_to_string(uvwasi_errno_t code);
7676

7777

78-
// WASI system call API.
78+
/* WASI system call API. */
7979
uvwasi_errno_t uvwasi_args_get(uvwasi_t* uvwasi, char** argv, char* argv_buf);
8080
uvwasi_errno_t uvwasi_args_sizes_get(uvwasi_t* uvwasi,
8181
size_t* argc,

deps/uvwasi/include/wasi_types.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <stddef.h>
55
#include <stdint.h>
66

7-
/* API: https://github.com./WebAssembly/WASI/blob/master/phases/unstable/docs/wasi_unstable_preview0.md */
7+
/* API: https://github.com./WebAssembly/WASI/blob/master/phases/snapshot/docs.md */
88

99
typedef uint8_t uvwasi_advice_t;
1010
#define UVWASI_ADVICE_NORMAL 0

deps/uvwasi/src/clocks.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ uvwasi_errno_t uvwasi__clock_gettime_thread_cputime(uvwasi_timestamp_t* time) {
153153
UVWASI__WIN_TIME_AND_RETURN(GetCurrentThread(), *time);
154154
#elif defined(__APPLE__)
155155
UVWASI__OSX_THREADTIME_AND_RETURN(*time);
156-
#elif defined(CLOCK_THREAD_CPUTIME_ID) && !defined(__sun)
156+
#elif defined(CLOCK_THREAD_CPUTIME_ID) && !defined(__sun) && !defined(__PASE__)
157157
UVWASI__CLOCK_GETTIME_AND_RETURN(CLOCK_THREAD_CPUTIME_ID, *time);
158158
#else
159159
# if defined(RUSAGE_LWP)
@@ -185,7 +185,7 @@ uvwasi_errno_t uvwasi__clock_getres_thread_cputime(uvwasi_timestamp_t* time) {
185185
UVWASI__WIN_GETRES_AND_RETURN(*time);
186186
#elif defined(__APPLE__)
187187
UVWASI__SLOW_GETRES_AND_RETURN(*time);
188-
#elif defined(CLOCK_THREAD_CPUTIME_ID) && !defined(__sun)
188+
#elif defined(CLOCK_THREAD_CPUTIME_ID) && !defined(__sun) && !defined(__PASE__)
189189
UVWASI__CLOCK_GETTIME_AND_RETURN(CLOCK_THREAD_CPUTIME_ID, *time);
190190
#elif defined(RUSAGE_THREAD) || defined(RUSAGE_LWP)
191191
UVWASI__SLOW_GETRES_AND_RETURN(*time);

deps/uvwasi/src/fd_table.c

+17-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "uv.h"
1010
#include "fd_table.h"
11+
#include "path_resolver.h"
1112
#include "wasi_types.h"
1213
#include "wasi_rights.h"
1314
#include "uv_mapping.h"
@@ -75,20 +76,33 @@ uvwasi_errno_t uvwasi_fd_table_insert(uvwasi_t* uvwasi,
7576
char* mp_copy;
7677
size_t rp_len;
7778
char* rp_copy;
79+
char* np_copy;
7880

7981
mp_len = strlen(mapped_path);
8082
rp_len = strlen(real_path);
83+
/* Reserve room for the mapped path, real path, and normalized mapped path. */
8184
entry = (struct uvwasi_fd_wrap_t*)
82-
uvwasi__malloc(uvwasi, sizeof(*entry) + mp_len + rp_len + 2);
83-
if (entry == NULL) return UVWASI_ENOMEM;
85+
uvwasi__malloc(uvwasi, sizeof(*entry) + mp_len + mp_len + rp_len + 3);
86+
if (entry == NULL)
87+
return UVWASI_ENOMEM;
8488

8589
mp_copy = (char*)(entry + 1);
8690
rp_copy = mp_copy + mp_len + 1;
91+
np_copy = rp_copy + rp_len + 1;
8792
memcpy(mp_copy, mapped_path, mp_len);
8893
mp_copy[mp_len] = '\0';
8994
memcpy(rp_copy, real_path, rp_len);
9095
rp_copy[rp_len] = '\0';
9196

97+
/* Calculate the normalized version of the mapped path, as it will be used for
98+
any path calculations on this fd. Use the length of the mapped path as an
99+
upper bound for the normalized path length. */
100+
err = uvwasi__normalize_path(mp_copy, mp_len, np_copy, mp_len);
101+
if (err) {
102+
uvwasi__free(uvwasi, entry);
103+
goto exit;
104+
}
105+
92106
uv_rwlock_wrlock(&table->rwlock);
93107

94108
/* Check that there is room for a new item. If there isn't, grow the table. */
@@ -138,6 +152,7 @@ uvwasi_errno_t uvwasi_fd_table_insert(uvwasi_t* uvwasi,
138152
entry->fd = fd;
139153
entry->path = mp_copy;
140154
entry->real_path = rp_copy;
155+
entry->normalized_path = np_copy;
141156
entry->type = type;
142157
entry->rights_base = rights_base;
143158
entry->rights_inheriting = rights_inheriting;

0 commit comments

Comments
 (0)