Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix, windows: fix uv_fs_chown() function prototype
Browse files Browse the repository at this point in the history
Before this commit, uv_fs_chown() and uv_fs_fchown() took the uid and
gid as 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 is not an ABI change because the size of the uid and gid arguments
do not change, only their sign.

On Windows, uv_uid_t and uv_gid_t are typedef'd as unsigned char for
reasons that are unclear. It doesn't matter: they get cast to ints when
used as function arguments. The arguments themselves are unused.

Partial fix for nodejs/node-v0.x-archive#5890.
  • Loading branch information
bnoordhuis committed Jul 23, 2013
1 parent 3b4e0a2 commit d779eb5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions include/uv-private/uv-unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ typedef struct {
void* buf; \
size_t len; \
off_t off; \
uid_t uid; \
gid_t gid; \
uv_uid_t uid; \
uv_gid_t gid; \
double atime; \
double mtime; \
struct uv__work work_req; \
Expand Down
4 changes: 2 additions & 2 deletions include/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1642,10 +1642,10 @@ UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file,
int mode, uv_fs_cb cb);

UV_EXTERN int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path,
int uid, int gid, uv_fs_cb cb);
uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb);

UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file,
int uid, int gid, uv_fs_cb cb);
uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb);


enum uv_fs_event {
Expand Down
8 changes: 4 additions & 4 deletions src/unix/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ int uv_fs_chmod(uv_loop_t* loop,
int uv_fs_chown(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
int uid,
int gid,
uv_uid_t uid,
uv_gid_t gid,
uv_fs_cb cb) {
INIT(CHOWN);
PATH;
Expand Down Expand Up @@ -631,8 +631,8 @@ int uv_fs_fchmod(uv_loop_t* loop,
int uv_fs_fchown(uv_loop_t* loop,
uv_fs_t* req,
uv_file file,
int uid,
int gid,
uv_uid_t uid,
uv_gid_t gid,
uv_fs_cb cb) {
INIT(FCHOWN);
req->file = file;
Expand Down
8 changes: 4 additions & 4 deletions src/win/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1672,8 +1672,8 @@ int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
}


int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, int uid,
int gid, uv_fs_cb cb) {
int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid,
uv_gid_t gid, uv_fs_cb cb) {
uv_fs_req_init(loop, req, UV_FS_CHOWN, cb);

if (fs__capture_path(loop, req, path, NULL, cb != NULL) < 0) {
Expand All @@ -1691,8 +1691,8 @@ int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, int uid,
}


int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file fd, int uid,
int gid, uv_fs_cb cb) {
int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_uid_t uid,
uv_gid_t gid, uv_fs_cb cb) {
uv_fs_req_init(loop, req, UV_FS_FCHOWN, cb);

if (cb) {
Expand Down

0 comments on commit d779eb5

Please sign in to comment.