diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-07-23 13:28:14 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-07-23 13:36:46 +0200 |
commit | ed806385bfd6d7d0e7e31b49586a78dd33d82d37 (patch) | |
tree | 68f7e1058a506833f77c418c11674f4fae153e24 /src | |
parent | 14f45ba739ac660fd437df9fc4a10415fa35d9a4 (diff) | |
download | android-node-v8-ed806385bfd6d7d0e7e31b49586a78dd33d82d37.tar.gz android-node-v8-ed806385bfd6d7d0e7e31b49586a78dd33d82d37.tar.bz2 android-node-v8-ed806385bfd6d7d0e7e31b49586a78dd33d82d37.zip |
fs: uids and gids must be unsigned ints
Before this commit, fs.chown() and fs.fchown() coerced the uid and gid
arguments to signed integers which is wrong because uid_t and gid_t are
unsigned on most all platforms and IDs that don't fit in a signed
integer do exist.
This commit changes the aforementioned functions to take unsigned ints
instead. No test because we can't assume the system has [GU]IDs that
large.
This change depends on joyent/libuv@d779eb5.
Fixes #5890.
Diffstat (limited to 'src')
-rw-r--r-- | src/node_file.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/node_file.cc b/src/node_file.cc index c4441bd125..589ecdf7c9 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -826,12 +826,12 @@ static Handle<Value> Chown(const Arguments& args) { if (len < 2) return TYPE_ERROR("uid required"); if (len < 3) return TYPE_ERROR("gid required"); if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); - if (!args[1]->IsInt32()) return TYPE_ERROR("uid must be an int"); - if (!args[2]->IsInt32()) return TYPE_ERROR("gid must be an int"); + if (!args[1]->IsUint32()) return TYPE_ERROR("uid must be an unsigned int"); + if (!args[2]->IsUint32()) return TYPE_ERROR("gid must be an unsigned int"); String::Utf8Value path(args[0]); - int uid = static_cast<int>(args[1]->Int32Value()); - int gid = static_cast<int>(args[2]->Int32Value()); + uv_uid_t uid = static_cast<uv_uid_t>(args[1]->Uint32Value()); + uv_gid_t gid = static_cast<uv_gid_t>(args[2]->Uint32Value()); if (args[3]->IsFunction()) { ASYNC_CALL(chown, args[3], *path, uid, gid); @@ -853,12 +853,12 @@ static Handle<Value> FChown(const Arguments& args) { if (len < 2) return TYPE_ERROR("uid required"); if (len < 3) return TYPE_ERROR("gid required"); if (!args[0]->IsInt32()) return TYPE_ERROR("fd must be an int"); - if (!args[1]->IsInt32()) return TYPE_ERROR("uid must be an int"); - if (!args[2]->IsInt32()) return TYPE_ERROR("gid must be an int"); + if (!args[1]->IsUint32()) return TYPE_ERROR("uid must be an unsigned int"); + if (!args[2]->IsUint32()) return TYPE_ERROR("gid must be an unsigned int"); int fd = args[0]->Int32Value(); - int uid = static_cast<int>(args[1]->Int32Value()); - int gid = static_cast<int>(args[2]->Int32Value()); + uv_uid_t uid = static_cast<uv_uid_t>(args[1]->Uint32Value()); + uv_gid_t gid = static_cast<uv_gid_t>(args[2]->Uint32Value()); if (args[3]->IsFunction()) { ASYNC_CALL(fchown, args[3], fd, uid, gid); |