Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZach Bjornson <zbbjornson@gmail.com>2021-05-05 08:24:29 +0300
committerJames M Snell <jasnell@gmail.com>2021-05-11 01:04:37 +0300
commit8886b63cf66c29d453fdc1ece2e489dace97ae9d (patch)
tree75b7342d5f77883f7323bd45105adc5fc07a6253 /src
parent16982b6c4d7c384c69b25bc2569eb76d5fbeb4c1 (diff)
fs: fix error when writing buffers > INT32_MAX
This reverts c380ee6785b72fd2f24803de80bb412dfc32e8a9. uv_fs_write returns an int, so it is not possible to ask it to write more than INT32_MAX. Instead, validate 'length' is an int32 in JS to avoid the assertion failure. PR-URL: https://github.com/nodejs/node/pull/38546 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_file.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/node_file.cc b/src/node_file.cc
index b8902f6b348..d3bcb8fbd80 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -1835,8 +1835,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(IsSafeJsInt(args[3]));
- const size_t len = static_cast<size_t>(args[3].As<Integer>()->Value());
+ CHECK(args[3]->IsInt32());
+ const size_t len = static_cast<size_t>(args[3].As<Int32>()->Value());
CHECK(Buffer::IsWithinBounds(off, len, buffer_length));
CHECK_LE(len, buffer_length);
CHECK_GE(off + len, off);