From 96ca59fbf382773bd937e9e4ca06d23845dae46d Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 17 Sep 2012 07:17:11 +0200 Subject: [PATCH] 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. --- src/node.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/node.cc b/src/node.cc index 309fc963836..7026cec7737 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1508,6 +1508,7 @@ static Handle 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 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)