mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
Reserve exec argv storage before inserting configured and CLI-expanded arguments so vector reallocation cannot invalidate pointers in argv. Signed-off-by: Archkon <180910180+Archkon@users.noreply.github.com> PR-URL: https://github.com/nodejs/node/pull/64755 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh>
60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const {
|
|
buildSEA,
|
|
skipIfBuildSEAIsNotSupported,
|
|
} = require('../common/sea');
|
|
|
|
skipIfBuildSEAIsNotSupported();
|
|
|
|
// This tests the execArgvExtension "cli" mode in single executable applications.
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
const { spawnSyncAndAssert } = require('../common/child_process');
|
|
const { join } = require('path');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
tmpdir.refresh();
|
|
|
|
const outputFile = buildSEA(fixtures.path('sea', 'exec-argv-extension-cli'));
|
|
|
|
const env = {
|
|
...process.env,
|
|
NODE_OPTIONS: '--max-old-space-size=2048', // Should be ignored
|
|
COMMON_DIRECTORY: join(__dirname, '..', 'common'),
|
|
NODE_DEBUG_NATIVE: 'SEA',
|
|
};
|
|
|
|
// Test that --node-options works with execArgvExtension: "cli"
|
|
spawnSyncAndAssert(
|
|
outputFile,
|
|
[
|
|
'--node-options=--no-warnings --max-old-space-size=1024',
|
|
'user-arg1',
|
|
'user-arg2',
|
|
],
|
|
{
|
|
env,
|
|
},
|
|
{
|
|
stdout: /execArgvExtension cli test passed/,
|
|
});
|
|
|
|
// Test that malformed --node-options values are rejected.
|
|
[
|
|
['--no-warnings "', /unterminated string/],
|
|
['"--no-warnings\\', /invalid escape/],
|
|
].forEach(([nodeOptions, stderr]) => {
|
|
spawnSyncAndAssert(
|
|
outputFile,
|
|
[`--node-options=${nodeOptions}`],
|
|
{ env },
|
|
{
|
|
status: 9,
|
|
stdout: '',
|
|
stderr,
|
|
});
|
|
});
|