Skip to content

Commit 6a26eee

Browse files
cjihrigcodebytere
authored andcommitted
wasi: fix poll_oneoff memory interface
The WASM memory interfacing logic was wrong (particularly around the size of __wasi_subscription_t). This commit fixes the logic. PR-URL: #33250 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
1 parent ed41494 commit 6a26eee

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/node_wasi.cc

+13-13
Original file line numberDiff line numberDiff line change
@@ -1456,21 +1456,21 @@ void WASI::PollOneoff(const FunctionCallbackInfo<Value>& args) {
14561456
}
14571457

14581458
for (uint32_t i = 0; i < nsubscriptions; ++i) {
1459-
uvwasi_subscription_t sub = in[i];
1460-
wasi->readUInt64(memory, &sub.userdata, in_ptr);
1461-
wasi->readUInt8(memory, &sub.type, in_ptr + 8);
1462-
1463-
if (sub.type == UVWASI_EVENTTYPE_CLOCK) {
1464-
wasi->readUInt32(memory, &sub.u.clock.clock_id, in_ptr + 16);
1465-
wasi->readUInt64(memory, &sub.u.clock.timeout, in_ptr + 24);
1466-
wasi->readUInt64(memory, &sub.u.clock.precision, in_ptr + 32);
1467-
wasi->readUInt16(memory, &sub.u.clock.flags, in_ptr + 40);
1468-
} else if (sub.type == UVWASI_EVENTTYPE_FD_READ ||
1469-
sub.type == UVWASI_EVENTTYPE_FD_WRITE) {
1470-
wasi->readUInt32(memory, &sub.u.fd_readwrite.fd, in_ptr + 16);
1459+
uvwasi_subscription_t* sub = &in[i];
1460+
wasi->readUInt64(memory, &sub->userdata, in_ptr);
1461+
wasi->readUInt8(memory, &sub->type, in_ptr + 8);
1462+
1463+
if (sub->type == UVWASI_EVENTTYPE_CLOCK) {
1464+
wasi->readUInt32(memory, &sub->u.clock.clock_id, in_ptr + 16);
1465+
wasi->readUInt64(memory, &sub->u.clock.timeout, in_ptr + 24);
1466+
wasi->readUInt64(memory, &sub->u.clock.precision, in_ptr + 32);
1467+
wasi->readUInt16(memory, &sub->u.clock.flags, in_ptr + 40);
1468+
} else if (sub->type == UVWASI_EVENTTYPE_FD_READ ||
1469+
sub->type == UVWASI_EVENTTYPE_FD_WRITE) {
1470+
wasi->readUInt32(memory, &sub->u.fd_readwrite.fd, in_ptr + 16);
14711471
}
14721472

1473-
in_ptr += 56;
1473+
in_ptr += 48;
14741474
}
14751475

14761476
size_t nevents;

0 commit comments

Comments
 (0)