diff --git a/lib/fs.js b/lib/fs.js index 6bc0f7c32ee78f..815018a855cde8 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -2030,7 +2030,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); } /** @@ -2044,7 +2044,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); } /** diff --git a/src/node_file.cc b/src/node_file.cc index a8ae691d4b0453..52c6c0e71f711e 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -2598,8 +2598,10 @@ static void FChown(const FunctionCallbackInfo& args) { const int argc = args.Length(); CHECK_GE(argc, 3); - CHECK(args[0]->IsInt32()); - const int fd = args[0].As()->Value(); + int fd; + if (!GetValidatedFd(env, args[0]).To(&fd)) { + return; + } CHECK(IsSafeJsInt(args[1])); const uv_uid_t uid = static_cast(args[1].As()->Value());