| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Escaping an empty handle isn't necessary. I realize this is copied from existing code, though.
Sorry, something went wrong.
There was a problem hiding this comment.
I’ll remove that in all locations here, then
Sorry, something went wrong.
|
LGTM. Technically, it's uv_stat_t, not struct stat. |
Sorry, something went wrong.
`FChown` and `Chown` test that the `uid` and `gid` parameters they receive are unsigned integers, but `Stat()` and `FStat()` would return the corresponding fields of `uv_stat_t` as signed integers. Applications which pass those these values directly to `Chown` may fail (e.g. for `nobody` on OS X, who has an `uid` of `-2`, see e.g. nodejs/node-v0.x-archive#5890). This patch changes the `Integer::New()` call for `uid` and `gid` to `Integer::NewFromUnsigned()`. All other fields are kept as they are, for performance, but strictly speaking the respective sizes of those fields aren’t specified, either. Ref: npm/npm#13918
|
Updated with uv_stat_t in the commit message and escaping the empty handles removed |
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
|
|
||
| // Integers. | ||
| #define X(name) \ | ||
| Local<Value> name = Integer::NewFromUnsigned(env->isolate(), s->st_##name); \ |
There was a problem hiding this comment.
This must be Integer::New, right?
Sorry, something went wrong.
There was a problem hiding this comment.
… yeah, sorry.
Sorry, something went wrong.
|
I am not sure, if I am looking in the right place. But if I am following the definition here, correctly, even dev, mode, nlink, and rdev are also unsigned it seems. |
Sorry, something went wrong.
|
@thefourtheye Yeah, that doesn’t look like the right place… usually, you’d want to take a peek at the public headers which define struct stat, but as Ben noted, libuv ships its own type for that. Either way, the result might be system-dependent, POSIX doesn’t seem to specify anything about size or signedness of the fields. That being said… yes, I’ve looked into it, and it seems the fields you mentioned are unsigned on Linux, too. Worse, dev, ino, nlink and rdev are 64 bit wide on my system, so using Integer::New(FromUnsigned) isn’t really appropriate… calling Number::New may be more correct, but it does seem to come with a slight but noticeable performance impact due to the extra range checking it does (about -1 % for me). |
Sorry, something went wrong.
Pragmatically though, those are going to fit in a uint32_t for the foreseeable future (maybe, just maybe, with the exception of ino.) |
Sorry, something went wrong.
|
So, we are going to leave them as signed for the time being? |
Sorry, something went wrong.
I’d be okay with that, if only for the fear of unnecessarily breaking things… alternatively, I can update this PR with something that auto-detects signedness of the fields? |
Sorry, something went wrong.
|
@addaleax Nah, we can keep it, simple, as it is. LGTM. I wonder how our CITGM never got this. |
Sorry, something went wrong.
I think one of the reasons is that it leaves quite a lot of code intact, it just blows up when you try to pass the uid/git to chown or fchown… but that’s not something you can’t usually do without root. As long as I’m not missing anything, doing an actual, working chown is basically untested by Node. :/ |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM but I wonder if there's a regression test that could be added for this.
Sorry, something went wrong.
|
@jasnell Maybe I could get a cctest for this together… I’ll look into that as soon as I have the time, but I kind of don’t want to block this PR on that because this PR itself would be a blocker for updating to npm@3.10.8 in deps/. |
Sorry, something went wrong.
Sorry, something went wrong.
`FChown` and `Chown` test that the `uid` and `gid` parameters they receive are unsigned integers, but `Stat()` and `FStat()` would return the corresponding fields of `uv_stat_t` as signed integers. Applications which pass those these values directly to `Chown` may fail (e.g. for `nobody` on OS X, who has an `uid` of `-2`, see e.g. nodejs/node-v0.x-archive#5890). This patch changes the `Integer::New()` call for `uid` and `gid` to `Integer::NewFromUnsigned()`. All other fields are kept as they are, for performance, but strictly speaking the respective sizes of those fields aren’t specified, either. Ref: npm/npm#13918 PR-URL: #8515 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> undo accidental change to other fields of uv_fs_stat
At the time of writing, all currently published versions of Node.js return signed 32-bit integers in their return values for the `uid` and `gid` fields of `fs.Stats` instances. This is problematic, because some of Node’s other `fs` methods like `chown` expect unsigned 32-bit integer input and throw when encountering negative integers; this has broken e.g. `sudo npm install -g` on `OS X`, where `nobody` has a UID that would be returned as `-2` by `fs.stat()`. Ref: nodejs/node#8515 Ref: npm/npm#13918
`FChown` and `Chown` test that the `uid` and `gid` parameters they receive are unsigned integers, but `Stat()` and `FStat()` would return the corresponding fields of `uv_stat_t` as signed integers. Applications which pass those these values directly to `Chown` may fail (e.g. for `nobody` on OS X, who has an `uid` of `-2`, see e.g. nodejs/node-v0.x-archive#5890). This patch changes the `Integer::New()` call for `uid` and `gid` to `Integer::NewFromUnsigned()`. All other fields are kept as they are, for performance, but strictly speaking the respective sizes of those fields aren’t specified, either. Ref: npm/npm#13918 PR-URL: #8515 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> undo accidental change to other fields of uv_fs_stat
|
@addaleax should this be backported? |
Sorry, something went wrong.
|
@thealphanerd This seems to land cleanly on v4.x-staging with tests passing, and it makes sense to have this on LTS for me. |
Sorry, something went wrong.
`FChown` and `Chown` test that the `uid` and `gid` parameters they receive are unsigned integers, but `Stat()` and `FStat()` would return the corresponding fields of `uv_stat_t` as signed integers. Applications which pass those these values directly to `Chown` may fail (e.g. for `nobody` on OS X, who has an `uid` of `-2`, see e.g. nodejs/node-v0.x-archive#5890). This patch changes the `Integer::New()` call for `uid` and `gid` to `Integer::NewFromUnsigned()`. All other fields are kept as they are, for performance, but strictly speaking the respective sizes of those fields aren’t specified, either. Ref: npm/npm#13918 PR-URL: #8515 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> undo accidental change to other fields of uv_fs_stat
`FChown` and `Chown` test that the `uid` and `gid` parameters they receive are unsigned integers, but `Stat()` and `FStat()` would return the corresponding fields of `uv_stat_t` as signed integers. Applications which pass those these values directly to `Chown` may fail (e.g. for `nobody` on OS X, who has an `uid` of `-2`, see e.g. nodejs/node-v0.x-archive#5890). This patch changes the `Integer::New()` call for `uid` and `gid` to `Integer::NewFromUnsigned()`. All other fields are kept as they are, for performance, but strictly speaking the respective sizes of those fields aren’t specified, either. Ref: npm/npm#13918 PR-URL: #8515 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> undo accidental change to other fields of uv_fs_stat
| Back | FazBrowse Home | New Git URL |
Checklist
Affected core subsystem(s)
fs
Description of change
FChown and Chown test that the uid and gid parameters they receive are unsigned integers, but Stat() and FStat() would return the corresponding fields of struct stat as signed integers. Applications which pass those these values directly to Chown may fail
(e.g. for nobody on OS X, who has an uid of -2, see e.g. nodejs/node-v0.x-archive#5890).
This patch changes the Integer::New() call for uid and gid to Integer::NewFromUnsigned().
All other fields are kept as they are, for performance, but strictly speaking the respective sizes of those fields aren’t specified, either.
Ref: npm/npm#13918
/cc @nodejs/fs
CI: https://ci.nodejs.org/job/node-test-commit/5026/