diff options
author | Luca Casonato <hello@lcas.dev> | 2024-08-01 09:38:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-01 09:38:46 +0200 |
commit | f1fc708d816def60c5fc2fe7bb3e43d3d6f75ec6 (patch) | |
tree | ea16ff691621d7748e0e8de845d2fea3ff6eec0f /ext/node/polyfills/internal | |
parent | 5bd76609f7f3116b2804f1be24320d11bc45e151 (diff) |
fix(ext/crypto): respect offsets when writing into ab views in randomFillSync (#24816)
Diffstat (limited to 'ext/node/polyfills/internal')
-rw-r--r-- | ext/node/polyfills/internal/crypto/_randomFill.mjs | 4 |
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; |