mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
src: fix empty-named env var assertion failure
Setting an environment variable with an empty name on Windows resulted in an assertion failure, because it was checked for an '=' sign at the beginning without verifying the length was greater than 0. Fixes: https://github.com/nodejs/node/issues/32920 Refs: https://github.com/nodejs/node/pull/27310 PR-URL: https://github.com/nodejs/node/pull/32921 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
This commit is contained in:
parent
540f2785dd
commit
3ccdf8ad22
@ -121,7 +121,7 @@ void RealEnvStore::Set(Isolate* isolate,
|
||||
node::Utf8Value val(isolate, value);
|
||||
|
||||
#ifdef _WIN32
|
||||
if (key[0] == L'=') return;
|
||||
if (key.length() > 0 && key[0] == L'=') return;
|
||||
#endif
|
||||
uv_os_setenv(*key, *val);
|
||||
DateTimeConfigurationChangeNotification(isolate, key);
|
||||
|
@ -106,3 +106,11 @@ if (common.isWindows) {
|
||||
const keys = Object.keys(process.env);
|
||||
assert.ok(keys.length > 0);
|
||||
}
|
||||
|
||||
// Setting environment variables on Windows with empty names should not cause
|
||||
// an assertion failure.
|
||||
// https://github.com/nodejs/node/issues/32920
|
||||
{
|
||||
process.env[''] = '';
|
||||
assert.strictEqual(process.env[''], undefined);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user