fs: validate fd from cpp on fchown

PR-URL: https://github.com/nodejs/node/pull/52051
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
This commit is contained in:
Yagiz Nizipli authored and marco-ippolito committed 2024-05-03 08:29:51 +02:00
1 parent 33ad86c2be
commit 51d7cd5de8
2 files changed
+6 -4

No files matched your search

+2 -2
View File
@@ -2028,7 +2028,7 @@ function fchown(fd, uid, gid, callback) {
const req = new FSReqCallback();
req.oncomplete = callback;
binding.fchown(getValidatedFd(fd), uid, gid, req);
binding.fchown(fd, uid, gid, req);
}
/**
@@ -2042,7 +2042,7 @@ function fchownSync(fd, uid, gid) {
validateInteger(uid, 'uid', -1, kMaxUserId);
validateInteger(gid, 'gid', -1, kMaxUserId);
binding.fchown(getValidatedFd(fd), uid, gid);
binding.fchown(fd, uid, gid);
}
/**
+4 -2
View File
@@ -2695,8 +2695,10 @@ static void FChown(const FunctionCallbackInfo<Value>& args) {
const int argc = args.Length();
CHECK_GE(argc, 3);
CHECK(args[0]->IsInt32());
const int fd = args[0].As<Int32>()->Value();
int fd;
if (!GetValidatedFd(env, args[0]).To(&fd)) {
return;
}
CHECK(IsSafeJsInt(args[1]));
const uv_uid_t uid = static_cast<uv_uid_t>(args[1].As<Integer>()->Value());