From fe6e5e4c0e4c5a6b7741a2b4d0c3238887ca4847 Mon Sep 17 00:00:00 2001 From: raisinten Date: Mon, 28 Dec 2020 21:56:51 +0530 Subject: [PATCH] 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 Reviewed-By: Antoine du Hamel Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Yash Ladha Reviewed-By: Zeyu Yang --- src/node_file.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index 4e975530b2c63c..5abdc6a941c0d2 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1832,8 +1832,8 @@ static void WriteBuffer(const FunctionCallbackInfo& args) { CHECK_LE(static_cast(off_64), buffer_length); const size_t off = static_cast(off_64); - CHECK(args[3]->IsInt32()); - const size_t len = static_cast(args[3].As()->Value()); + CHECK(IsSafeJsInt(args[3])); + const size_t len = static_cast(args[3].As()->Value()); CHECK(Buffer::IsWithinBounds(off, len, buffer_length)); CHECK_LE(len, buffer_length); CHECK_GE(off + len, off);