Skip to content
Merged
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
32 changes: 15 additions & 17 deletions lib/internal/process/per_thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function wrapProcessMethods(binding) {
return true;
}

function execve(execPath, args = [], env) {
function execve(execPath, args = [], env = process.env) {
emitExperimentalWarning('process.execve');

const { isMainThread } = require('internal/worker');
Expand All @@ -301,22 +301,20 @@ function wrapProcessMethods(binding) {
}

const envArray = [];
if (env !== undefined) {
validateObject(env, 'env');

for (const { 0: key, 1: value } of ObjectEntries(env)) {
if (
typeof key !== 'string' ||
typeof value !== 'string' ||
StringPrototypeIncludes(key, '\u0000') ||
StringPrototypeIncludes(value, '\u0000')
) {
throw new ERR_INVALID_ARG_VALUE(
'env', env, 'must be an object with string keys and values without null bytes',
);
} else {
ArrayPrototypePush(envArray, `${key}=${value}`);
}
validateObject(env, 'env');

for (const { 0: key, 1: value } of ObjectEntries(env)) {
if (
typeof key !== 'string' ||
typeof value !== 'string' ||
StringPrototypeIncludes(key, '\u0000') ||
StringPrototypeIncludes(value, '\u0000')
) {
throw new ERR_INVALID_ARG_VALUE(
'env', env, 'must be an object with string keys and values without null bytes',
);
} else {
ArrayPrototypePush(envArray, `${key}=${value}`);
}
}

Expand Down
Loading