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 <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Yash Ladha <[email protected]>
Reviewed-By: Zeyu Yang <[email protected]>
  • Loading branch information
RaisinTen authored and danielleadams committed Jan 12, 2021
1 parent 5cb8b16 commit d5e1b82
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 d5e1b82

Please sign in to comment.