Fix getentropy/random_get in Node and shell#27122
Conversation
PR emscripten-core#26526 refactored random_get to return randomFill()'s value rather than a hardcoded 0, but the node and shell implementations of randomFill() were not updated.
ff25b8c to
1a62dc4
Compare
|
Hopefully the codesize checks will smile upon me... |
sbc100
left a comment
There was a problem hiding this comment.
Wow, that must have a pain to debug. Sorry about that :(
|
Yeah it's kind of... special... that |
|
Right, it calls |
And yet it won't coerse the number |
|
Ah so |
Really, I would expect |
|
It converts it to a string and ToBigInt happily converts a string to a bigint just not a number const bytes = new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, // magic + version
1, 6, 1, 96, 1, 126, 1, 127, // type section: (i64) -> i32
3, 2, 1, 0, // function section
7, 8, 1, 4, 119, 114, 97, 112, 0, 0, // export "wrap"
10, 7, 1, 5, 0, 32, 0, 167, 11, // code: local.get 0; i32.wrap_i64; end
]);
const arr = new Uint8Array([200]);
WebAssembly.instantiate(bytes).then(({ instance }) => {
const { wrap } = instance.exports;
console.log("result:", wrap(arr)); // logs 200
}); |
PR #26526 refactored random_get to return randomFill()'s value rather than a hardcoded 0, but the node and shell implementations of randomFill() were not updated.