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

* fix: oob string read when parsing node_options

* chore: re-enable test

* fix: missing linux server env for tests
This commit is contained in:
Robo 2025-03-25 19:33:10 +09:00 committed by GitHub
parent cfada0347e
commit 307d4f94c7
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);
});
}
});