diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-09-17 07:17:11 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-09-17 07:20:47 +0200 |
commit | 96ca59fbf382773bd937e9e4ca06d23845dae46d (patch) | |
tree | d1ae13d646c79af27ec51d73475f29f1934c3498 | |
parent | db5c26e3b57c5c0c5c3e84931bc73b701f0258d1 (diff) | |
download | node-new-96ca59fbf382773bd937e9e4ca06d23845dae46d.tar.gz |
process: fix setuid() and setgid() error reporting
Zero errno before calling getgrnam_r() or getpwnam_r(). If errno had previously
been clobbered, node would report the wrong error.
-rw-r--r-- | src/node.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/node.cc b/src/node.cc index 309fc96383..7026cec773 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1508,6 +1508,7 @@ static Handle<Value> SetGid(const Arguments& args) { struct group grp, *grpp = NULL; int err; + errno = 0; if ((err = getgrnam_r(*grpnam, &grp, getbuf, ARRAY_SIZE(getbuf), &grpp)) || grpp == NULL) { if (errno == 0) @@ -1548,6 +1549,7 @@ static Handle<Value> SetUid(const Arguments& args) { struct passwd pwd, *pwdp = NULL; int err; + errno = 0; if ((err = getpwnam_r(*pwnam, &pwd, getbuf, ARRAY_SIZE(getbuf), &pwdp)) || pwdp == NULL) { if (errno == 0) |