summaryrefslogtreecommitdiff
path: root/src/node.cc
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-03-06 15:25:18 +0100
committerJoyee Cheung <joyeec9h3@gmail.com>2019-03-11 23:30:27 +0800
commitee2d2638ad468782ca3d30b5aa3b39ff281b80c1 (patch)
tree5dc3e405dbd0275688a11606c34858fe57151575 /src/node.cc
parent148254744134793cd6556c9749658f3872b03d00 (diff)
downloadandroid-node-v8-ee2d2638ad468782ca3d30b5aa3b39ff281b80c1.tar.gz
android-node-v8-ee2d2638ad468782ca3d30b5aa3b39ff281b80c1.tar.bz2
android-node-v8-ee2d2638ad468782ca3d30b5aa3b39ff281b80c1.zip
process: delay creation of process.env after bootstrap/node.js
Make sure that no code is allowed to access process.env during the execution of bootstrap/node.js. PR-URL: https://github.com/nodejs/node/pull/26515 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node.cc')
-rw-r--r--src/node.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/node.cc b/src/node.cc
index 89217e47bc..94947cb34a 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -340,6 +340,16 @@ MaybeLocal<Value> RunBootstrapping(Environment* env) {
MaybeLocal<Value> result = ExecuteBootstrapper(
env, "internal/bootstrap/node", &node_params, &node_args);
+ Local<Object> env_var_proxy;
+ if (!CreateEnvVarProxy(context, isolate, env->as_callback_data())
+ .ToLocal(&env_var_proxy) ||
+ process
+ ->Set(env->context(),
+ FIXED_ONE_BYTE_STRING(env->isolate(), "env"),
+ env_var_proxy)
+ .IsNothing())
+ return MaybeLocal<Value>();
+
env->set_has_run_bootstrapping_code(true);
return scope.EscapeMaybe(result);