From 85739b6c5b5d12204a81de18ceddf2d357effb8b Mon Sep 17 00:00:00 2001 From: 现充 Date: Wed, 30 Aug 2017 17:57:12 +0800 Subject: child_process: ignore undef/proto values of env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At present, undefined values of env option will be transferred as a "undefined" string value, and values in prototype will also be included, which are not usual behaviors. This commit prevents those to be transferred to the environment of the child process. PR-URL: https://github.com/nodejs/node/pull/15089 Fixes: https://github.com/nodejs/node/issues/15087 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso --- lib/child_process.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/child_process.js b/lib/child_process.js index d1c4d2f290..f2c1a0c237 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -504,8 +504,11 @@ function normalizeSpawnArguments(file, args, options) { var env = options.env || process.env; var envPairs = []; - for (var key in env) { - envPairs.push(`${key}=${env[key]}`); + for (const key of Object.keys(env)) { + const value = env[key]; + if (value !== undefined) { + envPairs.push(`${key}=${value}`); + } } _convertCustomFds(options); -- cgit v1.2.3