fix: oob string read when parsing node_options (#46247)

* fix: oob string read when parsing node_options

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* chore: re-enable test

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* fix: missing linux server env for tests

Co-authored-by: deepak1556 <hop2deep@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
This commit is contained in:
trop[bot] 2025-03-25 08:14:33 -05:00 committed by GitHub
parent 7ee88bbdcb
commit 6f3c9fcf99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 51 additions and 9 deletions

View file

@ -10,9 +10,14 @@ const fixturePath = path.resolve(__dirname, 'fixtures', 'crash-cases');
let children: cp.ChildProcessWithoutNullStreams[] = [];
const runFixtureAndEnsureCleanExit = async (args: string[]) => {
const runFixtureAndEnsureCleanExit = async (args: string[], customEnv: NodeJS.ProcessEnv) => {
let out = '';
const child = cp.spawn(process.execPath, args);
const child = cp.spawn(process.execPath, args, {
env: {
...process.env,
...customEnv
}
});
children.push(child);
child.stdout.on('data', (chunk: Buffer) => {
out += chunk.toString();
@ -70,11 +75,16 @@ describe('crash cases', () => {
ifit(shouldRunCase(crashCase))(`the "${crashCase}" case should not crash`, () => {
const fixture = path.resolve(fixturePath, crashCase);
const argsFile = path.resolve(fixture, 'electron.args');
const envFile = path.resolve(fixture, 'electron.env.json');
const args = [fixture];
let env = process.env;
if (fs.existsSync(argsFile)) {
args.push(...fs.readFileSync(argsFile, 'utf8').trim().split('\n'));
}
return runFixtureAndEnsureCleanExit(args);
if (fs.existsSync(envFile)) {
env = JSON.parse(fs.readFileSync(envFile, 'utf8'));
}
return runFixtureAndEnsureCleanExit(args, env);
});
}
});