fs: accept non-32-bit length in writeBuffer

Since `length` is `size_t`, it can accept 64-bit integers too.

Refs: https://man7.org/linux/man-pages/man2/write.2.html
Fixes: https://github.com/nodejs/node/issues/36643

PR-URL: https://github.com/nodejs/node/pull/36667
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yash Ladha <yash@yashladha.in>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
This commit is contained in:
raisinten authored and Danielle Adams committed 2021-01-12 07:10:25 -05:00
1 parent 5cb8b16452
commit d5e1b82125
1 file changed
+2 -2
+2 -2
View File
@@ -1832,8 +1832,8 @@ static void WriteBuffer(const FunctionCallbackInfo<Value>& args) {
CHECK_LE(static_cast<uint64_t>(off_64), buffer_length);
const size_t off = static_cast<size_t>(off_64);
CHECK(args[3]->IsInt32());
const size_t len = static_cast<size_t>(args[3].As<Int32>()->Value());
CHECK(IsSafeJsInt(args[3]));
const size_t len = static_cast<size_t>(args[3].As<Integer>()->Value());
CHECK(Buffer::IsWithinBounds(off, len, buffer_length));
CHECK_LE(len, buffer_length);
CHECK_GE(off + len, off);