Skip to content

Commit

Permalink
fs: accept non-32-bit length in writeBuffer
Browse files Browse the repository at this point in the history
Since `length` is `size_t`, it can accept 64-bit integers too.

Refs: https://man7.org/linux/man-pages/man2/write.2.html
Fixes: #36643

PR-URL: #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>
  • Loading branch information
RaisinTen authored and nodejs-github-bot committed Dec 30, 2020
1 parent 1b7ac0c commit c380ee6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c380ee6

Please sign in to comment.