Compare commits
No commits in common. "03d7ec15ebd5d26422372e316dcacbbdd1dd4c55" and "b83170ffc860f91d23050992355a4319ce8d41b9" have entirely different histories.
03d7ec15eb
...
b83170ffc8
1 changed files with 1 additions and 21 deletions
|
|
@ -210,8 +210,6 @@ class Wasi {
|
||||||
// clock_res_get + clock_time_get touch this.instance.exports
|
// clock_res_get + clock_time_get touch this.instance.exports
|
||||||
// .memory; the old stubs were no-ops and didn't need binding.
|
// .memory; the old stubs were no-ops and didn't need binding.
|
||||||
"clock_res_get", "clock_time_get",
|
"clock_res_get", "clock_time_get",
|
||||||
// random_get now writes into this.instance.exports.memory too.
|
|
||||||
"random_get",
|
|
||||||
];
|
];
|
||||||
for (const name of m) this[name] = this[name].bind(this);
|
for (const name of m) this[name] = this[name].bind(this);
|
||||||
}
|
}
|
||||||
|
|
@ -758,25 +756,7 @@ class Wasi {
|
||||||
path_filestat_set_times() { return 0; }
|
path_filestat_set_times() { return 0; }
|
||||||
poll_oneoff() { return 0; }
|
poll_oneoff() { return 0; }
|
||||||
sched_yield() { return 0; }
|
sched_yield() { return 0; }
|
||||||
// WASI random_get(buf, buf_len): fill buf_len bytes at *buf with
|
random_get() { return 0; }
|
||||||
// high-quality randomness. The old stub returned success without
|
|
||||||
// writing anything, so the destination kept its prior contents (zero
|
|
||||||
// in practice) — every std::random_device user got all-zero
|
|
||||||
// "randomness". That collided WebRTC peer ids across tabs in 3DForts
|
|
||||||
// (Catcrafts/3DForts#50). Back it with crypto.getRandomValues, which
|
|
||||||
// is a CSPRNG. crypto.getRandomValues rejects views longer than 65536
|
|
||||||
// bytes, so chunk for buffers above that bound.
|
|
||||||
random_get(ptr, len) {
|
|
||||||
const MAX = 65536; // QuotaExceededError above this per the WebCrypto spec
|
|
||||||
for (let off = 0; off < len; off += MAX) {
|
|
||||||
const chunk = Math.min(MAX, len - off);
|
|
||||||
// Re-view per chunk: the buffer can detach/grow between calls,
|
|
||||||
// and a fresh view also keeps each slice within the 65536 cap.
|
|
||||||
const view = new Uint8Array(this.instance.exports.memory.buffer, ptr + off, chunk);
|
|
||||||
crypto.getRandomValues(view);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
sock_accept() { return 0; }
|
sock_accept() { return 0; }
|
||||||
sock_recv() { return 0; }
|
sock_recv() { return 0; }
|
||||||
sock_send() { return 0; }
|
sock_send() { return 0; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue