Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2016-06-22 22:57:13 +0300
committerBen Noordhuis <info@bnoordhuis.nl>2016-06-29 13:21:13 +0300
commited3d8b13ee9a705d89f9e0397d9e96519e7e47ac (patch)
treeea4c64d1d822e25c884f9933c0268888d5e4d0e0 /src/process_wrap.cc
parentc50e19220453039b08065f50eb2cd1713c402c4e (diff)
src: fix bad logic in uid/gid checks
Pointed out by Coverity. Introduced in commits 3546383c ("process_wrap: avoid leaking memory when throwing due to invalid arguments") and fa4eb47c ("bindings: add spawn_sync bindings"). The return statements inside the if blocks were dead code because their guard conditions always evaluated to false. Remove them. PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'src/process_wrap.cc')
-rw-r--r--src/process_wrap.cc14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/process_wrap.cc b/src/process_wrap.cc
index 2b214d1d47a..d574bf22965 100644
--- a/src/process_wrap.cc
+++ b/src/process_wrap.cc
@@ -123,12 +123,9 @@ class ProcessWrap : public HandleWrap {
// options.uid
Local<Value> uid_v = js_options->Get(env->uid_string());
if (uid_v->IsInt32()) {
- int32_t uid = uid_v->Int32Value();
- if (uid & ~((uv_uid_t) ~0)) {
- return env->ThrowRangeError("options.uid is out of range");
- }
+ const int32_t uid = uid_v->Int32Value(env->context()).FromJust();
options.flags |= UV_PROCESS_SETUID;
- options.uid = (uv_uid_t) uid;
+ options.uid = static_cast<uv_uid_t>(uid);
} else if (!uid_v->IsUndefined() && !uid_v->IsNull()) {
return env->ThrowTypeError("options.uid should be a number");
}
@@ -136,12 +133,9 @@ class ProcessWrap : public HandleWrap {
// options.gid
Local<Value> gid_v = js_options->Get(env->gid_string());
if (gid_v->IsInt32()) {
- int32_t gid = gid_v->Int32Value();
- if (gid & ~((uv_gid_t) ~0)) {
- return env->ThrowRangeError("options.gid is out of range");
- }
+ const int32_t gid = gid_v->Int32Value(env->context()).FromJust();
options.flags |= UV_PROCESS_SETGID;
- options.gid = (uv_gid_t) gid;
+ options.gid = static_cast<uv_gid_t>(gid);
} else if (!gid_v->IsUndefined() && !gid_v->IsNull()) {
return env->ThrowTypeError("options.gid should be a number");
}