Skip to content

Commit 22f2c2c

Browse files
cjihrigcodebytere
authored andcommittedJun 7, 2020
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 <anna@addaleax.net> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
1 parent ed62d43 commit 22f2c2c

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
@@ -1455,21 +1455,21 @@ void WASI::PollOneoff(const FunctionCallbackInfo<Value>& args) {
14551455
}
14561456

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

1472-
in_ptr += 56;
1472+
in_ptr += 48;
14731473
}
14741474

14751475
size_t nevents;

0 commit comments

Comments
 (0)
Please sign in to comment.