diff options
author | Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> | 2024-08-16 09:48:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-16 09:48:57 -0700 |
commit | ff4226a3cd20ef6cfb155ca206c745785b6e098f (patch) | |
tree | c845e539ec01f4261a7f824cb3d50f1b6e2d7ab4 /ext/node/polyfills/internal/fs/utils.mjs | |
parent | 4d1b263e91dc7b85e9c8cd1cb42270ddc0468396 (diff) |
fix(node/fs): Use correct offset and length in node:fs.read and write (#25049)
My fix in #25030 was buggy, I forgot to pass the `byteOffset` and
`byteLength`. Whoops.
I also discovered that fs.read was not respecting the `offset` argument,
and we were constructing a new `Buffer` for the callback instead of just
passing the original one (which is what node does, and the @types/node
definitions also indicate the callback should get the same type).
Fixes #25028.
Diffstat (limited to 'ext/node/polyfills/internal/fs/utils.mjs')
-rw-r--r-- | ext/node/polyfills/internal/fs/utils.mjs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/node/polyfills/internal/fs/utils.mjs b/ext/node/polyfills/internal/fs/utils.mjs index 53184b9c3..b0ef34873 100644 --- a/ext/node/polyfills/internal/fs/utils.mjs +++ b/ext/node/polyfills/internal/fs/utils.mjs @@ -990,7 +990,11 @@ export const validatePosition = hideStackFrames((position) => { export const arrayBufferViewToUint8Array = hideStackFrames( (buffer) => { if (!(buffer instanceof Uint8Array)) { - return new Uint8Array(buffer.buffer); + return new Uint8Array( + buffer.buffer, + buffer.byteOffset, + buffer.byteLength, + ); } return buffer; }, |