Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fs: validate fd from cpp on fchown
  • Loading branch information
anonrig committed Mar 12, 2024
commit 71508f7125b70bcdb471e19240e7840bb72b71ad
4 changes: 2 additions & 2 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2034,7 +2034,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);
}

/**
Expand All @@ -2048,7 +2048,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);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2593,8 +2593,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());
Expand Down