Skip to content

Commit 847dcf7

Browse files
committed
Merge commit from fork
1 parent 59a6381 commit 847dcf7

File tree

3 files changed

+34
-21
lines changed

3 files changed

+34
-21
lines changed

build-scripts/config_common.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,12 @@ else ()
279279
message (" Libc builtin disabled")
280280
endif ()
281281
if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
282-
message (" Libc WASI enabled with uvwasi implementation")
282+
message (" Libc WASI enabled with uvwasi implementation\n"
283+
" WANRING:: uvwasi does not currently provide the comprehensive\n"
284+
" file system security properties provided by some WASI runtimes.\n"
285+
" Full support for secure file system sandboxing may or may not\n"
286+
" be implemented in future. In the mean time, DO NOT RELY ON IT\n"
287+
" TO RUN UNTRUSTED CODE.")
283288
elseif (WAMR_BUILD_LIBC_WASI EQUAL 1)
284289
message (" Libc WASI enabled")
285290
else ()

core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE)
1010

1111
set (LIBC_WASI_DIR ${CMAKE_CURRENT_LIST_DIR})
1212

13-
set (LIBUV_VERSION v1.46.0)
13+
set (LIBUV_VERSION v1.51.0)
1414

1515
add_definitions (-DWASM_ENABLE_LIBC_WASI=1 -DWASM_ENABLE_UVWASI=1)
1616

@@ -29,15 +29,10 @@ else()
2929
GIT_REPOSITORY https://github.com/libuv/libuv.git
3030
GIT_TAG ${LIBUV_VERSION}
3131
)
32-
FetchContent_GetProperties(libuv)
33-
if (NOT libuv_POPULATED)
34-
message("-- Fetching libuv ..")
35-
FetchContent_Populate(libuv)
36-
include_directories("${libuv_SOURCE_DIR}/include")
37-
add_subdirectory(${libuv_SOURCE_DIR} ${libuv_BINARY_DIR} EXCLUDE_FROM_ALL)
38-
set (LIBUV_LIBRARIES uv_a)
39-
set_target_properties(uv_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
40-
endif()
32+
FetchContent_MakeAvailable(libuv)
33+
include_directories("${libuv_SOURCE_DIR}/include")
34+
set (LIBUV_LIBRARIES uv_a)
35+
set_target_properties(uv_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
4136
endif()
4237

4338
## uvwasi
@@ -48,17 +43,12 @@ else()
4843
FetchContent_Declare(
4944
uvwasi
5045
GIT_REPOSITORY https://github.com/nodejs/uvwasi.git
51-
GIT_TAG main
46+
GIT_TAG v0.0.21
5247
)
53-
FetchContent_GetProperties(uvwasi)
54-
if (NOT uvwasi_POPULATED)
55-
message("-- Fetching uvwasi ..")
56-
FetchContent_Populate(uvwasi)
57-
include_directories("${uvwasi_SOURCE_DIR}/include")
58-
add_subdirectory(${uvwasi_SOURCE_DIR} ${uvwasi_BINARY_DIR} EXCLUDE_FROM_ALL)
59-
set (UVWASI_LIBRARIES uvwasi_a)
60-
set_target_properties(uvwasi_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
61-
endif()
48+
FetchContent_MakeAvailable(uvwasi)
49+
include_directories("${uvwasi_SOURCE_DIR}/include")
50+
set (UVWASI_LIBRARIES uvwasi_a)
51+
set_target_properties(uvwasi_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
6252
endif()
6353

6454
set (UV_A_LIBS ${LIBUV_LIBRARIES} ${UVWASI_LIBRARIES})

core/iwasm/libraries/libc-uvwasi/libc_uvwasi_wrapper.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,24 @@ wasi_path_symlink(wasm_exec_env_t exec_env, const char *old_path,
890890
if (!uvwasi)
891891
return (wasi_errno_t)-1;
892892

893+
/*
894+
* check if old_path is valid.
895+
* if it is a symlink, follow it.
896+
*
897+
* this is a workaround for the fact that
898+
* uvwasi_path_symlink does not check if the old_path is valid
899+
*
900+
* the goal is trigger uvwasi__resolve_path() to check
901+
*/
902+
{
903+
uvwasi_filestat_t filestat = { 0 };
904+
wasi_errno_t err =
905+
uvwasi_path_filestat_get(uvwasi, fd, UVWASI_LOOKUP_SYMLINK_FOLLOW,
906+
old_path, old_path_len, &filestat);
907+
if (err)
908+
return err;
909+
}
910+
893911
return uvwasi_path_symlink(uvwasi, old_path, old_path_len, fd, new_path,
894912
new_path_len);
895913
}

0 commit comments

Comments
 (0)