diff options
author | cjihrig <cjihrig@gmail.com> | 2019-12-28 19:47:58 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2020-01-03 18:22:05 +0300 |
commit | 8491e1c3c6532827a69a2ad26347e910533e59ed (patch) | |
tree | 77cfccd8de913a8db96abb628b015eca4bb7ef80 /src/node_wasi.cc | |
parent | 799b50934bbbfa1205903291b5b58a0ffc012caa (diff) |
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: https://github.com/nodejs/node/pull/30980
PR-URL: https://github.com/nodejs/node/pull/31122
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/node_wasi.cc')
-rw-r--r-- | src/node_wasi.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/node_wasi.cc b/src/node_wasi.cc index 699c4c46991..277b171224c 100644 --- a/src/node_wasi.cc +++ b/src/node_wasi.cc @@ -545,7 +545,7 @@ void WASI::FdFilestatGet(const FunctionCallbackInfo<Value>& args) { ASSIGN_OR_RETURN_UNWRAP(&wasi, args.This()); Debug(wasi, "fd_filestat_get(%d, %d)\n", fd, buf); GET_BACKING_STORE_OR_RETURN(wasi, args, &memory, &mem_size); - CHECK_BOUNDS_OR_RETURN(args, mem_size, buf, 56); + CHECK_BOUNDS_OR_RETURN(args, mem_size, buf, 64); uvwasi_filestat_t stats; uvwasi_errno_t err = uvwasi_fd_filestat_get(&wasi->uvw_, fd, &stats); @@ -553,7 +553,7 @@ void WASI::FdFilestatGet(const FunctionCallbackInfo<Value>& args) { wasi->writeUInt64(memory, stats.st_dev, buf); wasi->writeUInt64(memory, stats.st_ino, buf + 8); wasi->writeUInt8(memory, stats.st_filetype, buf + 16); - wasi->writeUInt32(memory, stats.st_nlink, buf + 24); + wasi->writeUInt64(memory, stats.st_nlink, buf + 24); wasi->writeUInt64(memory, stats.st_size, buf + 32); wasi->writeUInt64(memory, stats.st_atim, buf + 40); wasi->writeUInt64(memory, stats.st_mtim, buf + 48); @@ -1069,7 +1069,7 @@ void WASI::PathFilestatGet(const FunctionCallbackInfo<Value>& args) { path_len); GET_BACKING_STORE_OR_RETURN(wasi, args, &memory, &mem_size); CHECK_BOUNDS_OR_RETURN(args, mem_size, path_ptr, path_len); - CHECK_BOUNDS_OR_RETURN(args, mem_size, buf_ptr, 56); + CHECK_BOUNDS_OR_RETURN(args, mem_size, buf_ptr, 64); uvwasi_filestat_t stats; uvwasi_errno_t err = uvwasi_path_filestat_get(&wasi->uvw_, fd, @@ -1081,7 +1081,7 @@ void WASI::PathFilestatGet(const FunctionCallbackInfo<Value>& args) { wasi->writeUInt64(memory, stats.st_dev, buf_ptr); wasi->writeUInt64(memory, stats.st_ino, buf_ptr + 8); wasi->writeUInt8(memory, stats.st_filetype, buf_ptr + 16); - wasi->writeUInt32(memory, stats.st_nlink, buf_ptr + 24); + wasi->writeUInt64(memory, stats.st_nlink, buf_ptr + 24); wasi->writeUInt64(memory, stats.st_size, buf_ptr + 32); wasi->writeUInt64(memory, stats.st_atim, buf_ptr + 40); wasi->writeUInt64(memory, stats.st_mtim, buf_ptr + 48); @@ -1423,7 +1423,7 @@ void WASI::PollOneoff(const FunctionCallbackInfo<Value>& args) { nsubscriptions, nevents_ptr); GET_BACKING_STORE_OR_RETURN(wasi, args, &memory, &mem_size); - CHECK_BOUNDS_OR_RETURN(args, mem_size, in_ptr, nsubscriptions * 56); + CHECK_BOUNDS_OR_RETURN(args, mem_size, in_ptr, nsubscriptions * 48); CHECK_BOUNDS_OR_RETURN(args, mem_size, out_ptr, nsubscriptions * 32); CHECK_BOUNDS_OR_RETURN(args, mem_size, nevents_ptr, 4); uvwasi_subscription_t* in = |