summaryrefslogtreecommitdiff
path: root/src/node_file.cc
diff options
context:
space:
mode:
authorZach Bjornson <zbbjornson@gmail.com>2019-03-27 15:23:59 -0700
committerRich Trott <rtrott@gmail.com>2019-08-16 22:09:34 -0700
commit5e3b4d6ed957ca03ae7178c7697549f470b6d86e (patch)
tree8f760f4796cb92a6f049a26269b3718e0637ae60 /src/node_file.cc
parenta3c0014e73dcc04718e0d3baf07dd6c453ec6db0 (diff)
downloadandroid-node-v8-5e3b4d6ed957ca03ae7178c7697549f470b6d86e.tar.gz
android-node-v8-5e3b4d6ed957ca03ae7178c7697549f470b6d86e.tar.bz2
android-node-v8-5e3b4d6ed957ca03ae7178c7697549f470b6d86e.zip
fs: allow int64 offset in fs.write/writeSync/fd.write
Ref https://github.com/nodejs/node/issues/26563 PR-URL: https://github.com/nodejs/node/pull/26572 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/node_file.cc')
-rw-r--r--src/node_file.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/node_file.cc b/src/node_file.cc
index 4301cdc7b4..c4e3b83392 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -88,7 +88,7 @@ constexpr char kPathSeparator = '/';
const char* const kPathSeparator = "\\/";
#endif
-#define GET_OFFSET(a) ((a)->IsNumber() ? (a).As<Integer>()->Value() : -1)
+#define GET_OFFSET(a) (IsSafeJsInt(a) ? (a).As<Integer>()->Value() : -1)
#define TRACE_NAME(name) "fs.sync." #name
#define GET_TRACE_ENABLED \
(*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \
@@ -1669,9 +1669,11 @@ static void WriteBuffer(const FunctionCallbackInfo<Value>& args) {
char* buffer_data = Buffer::Data(buffer_obj);
size_t buffer_length = Buffer::Length(buffer_obj);
- CHECK(args[2]->IsInt32());
- const size_t off = static_cast<size_t>(args[2].As<Int32>()->Value());
- CHECK_LE(off, buffer_length);
+ CHECK(IsSafeJsInt(args[2]));
+ const int64_t off_64 = args[2].As<Integer>()->Value();
+ CHECK_GE(off_64, 0);
+ 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());