diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2023-11-28 22:28:07 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-28 22:28:07 +0900 |
commit | 567d7ff923b75ad14e611ef53a0720c6c27fe266 (patch) | |
tree | 85a543a037482b0fcd51e3d22f3065d0e6ab7b1f /ext/node/polyfills/internal/buffer.mjs | |
parent | 4ed9278bf4c47670d9dda61a0d6e07e82cba3992 (diff) |
fix(ext/node): fix Buffer.copy when sourceStart > source.length (#21345)
Diffstat (limited to 'ext/node/polyfills/internal/buffer.mjs')
-rw-r--r-- | ext/node/polyfills/internal/buffer.mjs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/node/polyfills/internal/buffer.mjs b/ext/node/polyfills/internal/buffer.mjs index cd69a199f..4d50fe80f 100644 --- a/ext/node/polyfills/internal/buffer.mjs +++ b/ext/node/polyfills/internal/buffer.mjs @@ -1536,8 +1536,12 @@ Buffer.prototype.copy = function copy( sourceStart = 0; } else { sourceStart = toInteger(sourceStart, 0); - if (sourceStart < 0) { - throw new codes.ERR_OUT_OF_RANGE("sourceStart", ">= 0", sourceStart); + if (sourceStart < 0 || sourceStart > this.length) { + throw new codes.ERR_OUT_OF_RANGE( + "sourceStart", + `>= 0 && <= ${this.length}`, + sourceStart, + ); } if (sourceStart >= MAX_UINT32) { throw new codes.ERR_OUT_OF_RANGE( |