Skip to content

Commit 8491e1c

Browse files
cjihrigBridgeAR
authored andcommitted
wasi: fix serdes bugs from snapshot1 migration
During the migration to WASI snapshot1, a field was removed from the subscription type. The field was removed from the code, but the bounds checking logic was not updated. This commit updates that check. Similarly, __wasi_linkcount_t changed from a uint32_t to a uint64_t. However, the bounds checks were missed, and the code was still writing uint32_t's (to the new correct offset) instead of uint64_t's. This commit updates that logic as well. Refs: #30980 PR-URL: #31122 Reviewed-By: David Carlier <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 799b509 commit 8491e1c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/node_wasi.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -545,15 +545,15 @@ void WASI::FdFilestatGet(const FunctionCallbackInfo<Value>& args) {
545545
ASSIGN_OR_RETURN_UNWRAP(&wasi, args.This());
546546
Debug(wasi, "fd_filestat_get(%d, %d)\n", fd, buf);
547547
GET_BACKING_STORE_OR_RETURN(wasi, args, &memory, &mem_size);
548-
CHECK_BOUNDS_OR_RETURN(args, mem_size, buf, 56);
548+
CHECK_BOUNDS_OR_RETURN(args, mem_size, buf, 64);
549549
uvwasi_filestat_t stats;
550550
uvwasi_errno_t err = uvwasi_fd_filestat_get(&wasi->uvw_, fd, &stats);
551551

552552
if (err == UVWASI_ESUCCESS) {
553553
wasi->writeUInt64(memory, stats.st_dev, buf);
554554
wasi->writeUInt64(memory, stats.st_ino, buf + 8);
555555
wasi->writeUInt8(memory, stats.st_filetype, buf + 16);
556-
wasi->writeUInt32(memory, stats.st_nlink, buf + 24);
556+
wasi->writeUInt64(memory, stats.st_nlink, buf + 24);
557557
wasi->writeUInt64(memory, stats.st_size, buf + 32);
558558
wasi->writeUInt64(memory, stats.st_atim, buf + 40);
559559
wasi->writeUInt64(memory, stats.st_mtim, buf + 48);
@@ -1069,7 +1069,7 @@ void WASI::PathFilestatGet(const FunctionCallbackInfo<Value>& args) {
10691069
path_len);
10701070
GET_BACKING_STORE_OR_RETURN(wasi, args, &memory, &mem_size);
10711071
CHECK_BOUNDS_OR_RETURN(args, mem_size, path_ptr, path_len);
1072-
CHECK_BOUNDS_OR_RETURN(args, mem_size, buf_ptr, 56);
1072+
CHECK_BOUNDS_OR_RETURN(args, mem_size, buf_ptr, 64);
10731073
uvwasi_filestat_t stats;
10741074
uvwasi_errno_t err = uvwasi_path_filestat_get(&wasi->uvw_,
10751075
fd,
@@ -1081,7 +1081,7 @@ void WASI::PathFilestatGet(const FunctionCallbackInfo<Value>& args) {
10811081
wasi->writeUInt64(memory, stats.st_dev, buf_ptr);
10821082
wasi->writeUInt64(memory, stats.st_ino, buf_ptr + 8);
10831083
wasi->writeUInt8(memory, stats.st_filetype, buf_ptr + 16);
1084-
wasi->writeUInt32(memory, stats.st_nlink, buf_ptr + 24);
1084+
wasi->writeUInt64(memory, stats.st_nlink, buf_ptr + 24);
10851085
wasi->writeUInt64(memory, stats.st_size, buf_ptr + 32);
10861086
wasi->writeUInt64(memory, stats.st_atim, buf_ptr + 40);
10871087
wasi->writeUInt64(memory, stats.st_mtim, buf_ptr + 48);
@@ -1423,7 +1423,7 @@ void WASI::PollOneoff(const FunctionCallbackInfo<Value>& args) {
14231423
nsubscriptions,
14241424
nevents_ptr);
14251425
GET_BACKING_STORE_OR_RETURN(wasi, args, &memory, &mem_size);
1426-
CHECK_BOUNDS_OR_RETURN(args, mem_size, in_ptr, nsubscriptions * 56);
1426+
CHECK_BOUNDS_OR_RETURN(args, mem_size, in_ptr, nsubscriptions * 48);
14271427
CHECK_BOUNDS_OR_RETURN(args, mem_size, out_ptr, nsubscriptions * 32);
14281428
CHECK_BOUNDS_OR_RETURN(args, mem_size, nevents_ptr, 4);
14291429
uvwasi_subscription_t* in =

0 commit comments

Comments
 (0)