Browse Source

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.
v0.8.11-release
Ben Noordhuis 12 years ago
parent
commit
96ca59fbf3
  1. 2
      src/node.cc

2
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)

Loading…
Cancel
Save