Skip to content

fs: special input -1 on chown, lchown and fchown #58836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

himself65
Copy link
Member

@himself65 himself65 commented Jun 25, 2025

Fixes: #58826

-1 is a special input for chown, means won't change anything according to the spec.

https://stackoverflow.com/questions/21370094/is-the-uid-t-type-signed-or-unsigned

@himself65 himself65 marked this pull request as ready for review June 25, 2025 17:35
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Jun 25, 2025
@himself65 himself65 requested review from jasnell and joyeecheung June 25, 2025 17:36
@himself65
Copy link
Member Author

I didn't see any test about valid input in chown. well do we need add one?

Copy link

codecov bot commented Jun 25, 2025

Codecov Report

Attention: Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 90.07%. Comparing base (a705e24) to head (0a3e989).
Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
src/util-inl.h 25.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58836      +/-   ##
==========================================
- Coverage   90.08%   90.07%   -0.01%     
==========================================
  Files         640      640              
  Lines      188375   188447      +72     
  Branches    36939    36966      +27     
==========================================
+ Hits       169698   169745      +47     
- Misses      11397    11405       +8     
- Partials     7280     7297      +17     
Files with missing lines Coverage Δ
src/node_file.cc 75.79% <100.00%> (-0.04%) ⬇️
src/util-inl.h 81.90% <25.00%> (-0.28%) ⬇️

... and 33 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@himself65 himself65 force-pushed the himself65/2025/06/25/loose branch from f912834 to 6fa93e5 Compare June 25, 2025 23:34
@himself65 himself65 changed the title fs: edge case -1 input on chown fs: special input -1 on chown, lchown and fchown Jun 25, 2025
@himself65 himself65 force-pushed the himself65/2025/06/25/loose branch from 74479c1 to 64f6f95 Compare June 25, 2025 23:42
@himself65 himself65 force-pushed the himself65/2025/06/25/loose branch from 64f6f95 to 0a3e989 Compare June 26, 2025 16:03
@himself65 himself65 requested a review from joyeecheung June 26, 2025 16:04
@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 27, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 27, 2025
@nodejs-github-bot
Copy link
Collaborator

@himself65 himself65 added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 27, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 27, 2025
@nodejs-github-bot
Copy link
Collaborator

CHECK(value->IsUint32());
} else {
CHECK(value->IsNumber());
}
return static_cast<T>(value.As<v8::Uint32>()->Value());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure that at least according to the V8 API contract, IsUint32() is a prerequisite for this case to be valid in the first place – overall, I'd say it's better to handle these values in the *Chown functions rather than in the generic helpers here

@himself65 himself65 added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 27, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 27, 2025
@nodejs-github-bot
Copy link
Collaborator

@himself65 himself65 added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 27, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 27, 2025
@nodejs-github-bot
Copy link
Collaborator

@himself65 himself65 added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 27, 2025
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 27, 2025
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/58836
✔  Done loading data for nodejs/node/pull/58836
----------------------------------- PR info ------------------------------------
Title      fs: special input `-1` on `chown`, `lchown` and `fchown` (#58836)
Author     Alex Yang <[email protected]> (@himself65)
Branch     himself65:himself65/2025/06/25/loose -> nodejs:main
Labels     c++, fs, needs-ci
Commits    1
 - fs: special input `-1` on `chown`, `lchown` and `fchown`
Committers 1
 - Alex Yang <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/58836
Fixes: https://github.com/nodejs/node/issues/58826
Reviewed-By: Joyee Cheung <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/58836
Fixes: https://github.com/nodejs/node/issues/58826
Reviewed-By: Joyee Cheung <[email protected]>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Wed, 25 Jun 2025 17:35:29 GMT
   ✔  Approvals: 1
   ✔  - Joyee Cheung (@joyeecheung) (TSC): https://github.com/nodejs/node/pull/58836#pullrequestreview-2965372044
   ✘  This PR needs to wait 116 more hours to land (or 0 hours if there is one more approval)
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2025-06-27T20:21:59Z: https://ci.nodejs.org/job/node-test-pull-request/67691/
- Querying data for job/node-test-pull-request/67691/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/15936207250

@himself65 himself65 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fs.chown crashes when uid is -1
4 participants