Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
joyeecheung committed Mar 8, 2019
commit 75590f00c60271b37b04d765d223f5ae7cbd812a
10 changes: 10 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 0 additions & 12 deletions src/node_process_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,6 @@ MaybeLocal<Object> CreateProcessObject(
ToV8Value(env->context(), exec_args)
.ToLocalChecked()).FromJust();

Local<Object> env_var_proxy;
if (!CreateEnvVarProxy(context, isolate, env->as_callback_data())
.ToLocal(&env_var_proxy))
return MaybeLocal<Object>();

// process.env
process
->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "env"),
env_var_proxy)
.FromJust();

READONLY_PROPERTY(process, "pid",
Integer::New(env->isolate(), uv_os_getpid()));

Expand Down