Skip to content

Commit ee2d263

Browse files
committed
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: #26515 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 1482547 commit ee2d263

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/node.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,16 @@ MaybeLocal<Value> RunBootstrapping(Environment* env) {
340340
MaybeLocal<Value> result = ExecuteBootstrapper(
341341
env, "internal/bootstrap/node", &node_params, &node_args);
342342

343+
Local<Object> env_var_proxy;
344+
if (!CreateEnvVarProxy(context, isolate, env->as_callback_data())
345+
.ToLocal(&env_var_proxy) ||
346+
process
347+
->Set(env->context(),
348+
FIXED_ONE_BYTE_STRING(env->isolate(), "env"),
349+
env_var_proxy)
350+
.IsNothing())
351+
return MaybeLocal<Value>();
352+
343353
env->set_has_run_bootstrapping_code(true);
344354

345355
return scope.EscapeMaybe(result);

src/node_process_object.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,6 @@ MaybeLocal<Object> CreateProcessObject(
151151
ToV8Value(env->context(), exec_args)
152152
.ToLocalChecked()).FromJust();
153153

154-
Local<Object> env_var_proxy;
155-
if (!CreateEnvVarProxy(context, isolate, env->as_callback_data())
156-
.ToLocal(&env_var_proxy))
157-
return MaybeLocal<Object>();
158-
159-
// process.env
160-
process
161-
->Set(env->context(),
162-
FIXED_ONE_BYTE_STRING(env->isolate(), "env"),
163-
env_var_proxy)
164-
.FromJust();
165-
166154
READONLY_PROPERTY(process, "pid",
167155
Integer::New(env->isolate(), uv_os_getpid()));
168156

0 commit comments

Comments
 (0)