summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal/crypto/_randomFill.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/internal/crypto/_randomFill.mjs')
-rw-r--r--ext/node/polyfills/internal/crypto/_randomFill.mjs4
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/node/polyfills/internal/crypto/_randomFill.mjs b/ext/node/polyfills/internal/crypto/_randomFill.mjs
index 5de756536..e53918b39 100644
--- a/ext/node/polyfills/internal/crypto/_randomFill.mjs
+++ b/ext/node/polyfills/internal/crypto/_randomFill.mjs
@@ -86,7 +86,9 @@ export function randomFillSync(buf, offset = 0, size) {
return buf;
}
- const bytes = new Uint8Array(buf.buffer ? buf.buffer : buf, offset, size);
+ const bytes = isAnyArrayBuffer(buf)
+ ? new Uint8Array(buf, offset, size)
+ : new Uint8Array(buf.buffer, buf.byteOffset + offset, size);
op_node_generate_secret(bytes);
return buf;