fix(ghidra): avoid nested quotes in Windows Java options
This commit is contained in:
@@ -312,10 +312,10 @@ const ghidraLaunchEnvironment = (
|
||||
javaHome: string | undefined,
|
||||
platform: NodeJS.Platform,
|
||||
): NodeJS.ProcessEnv => {
|
||||
const javaOptions =
|
||||
platform === "win32"
|
||||
? `"-Duser.home=${paths.homeRoot}" "-Djava.io.tmpdir=${paths.tempRoot}"`
|
||||
: `-Duser.home=${paths.homeRoot} -Djava.io.tmpdir=${paths.tempRoot}`;
|
||||
// analyzeHeadless.bat wraps GHIDRA_HEADLESS_JAVA_OPTIONS in its own quotes
|
||||
// when it builds VMARG_LIST. Nested quotes break cmd.exe tokenization before
|
||||
// Ghidra starts, so keep this option list unquoted on every platform.
|
||||
const javaOptions = `-Duser.home=${paths.homeRoot} -Djava.io.tmpdir=${paths.tempRoot}`;
|
||||
return {
|
||||
...ghidraJavaEnvironment(javaHome, process.env, platform),
|
||||
HOME: paths.homeRoot,
|
||||
|
||||
@@ -200,6 +200,13 @@ describe("Ghidra headless launcher", () => {
|
||||
expect(capture.environment.GHIDRA_HEADLESS_JAVA_OPTIONS).toContain(
|
||||
`-Duser.home=${join(runtimeRoot, "home")}`,
|
||||
);
|
||||
expect(capture.environment.GHIDRA_HEADLESS_JAVA_OPTIONS).toBe(
|
||||
`-Duser.home=${join(runtimeRoot, "home")} -Djava.io.tmpdir=${join(runtimeRoot, "tmp")}`,
|
||||
);
|
||||
if (process.platform === "win32")
|
||||
expect(capture.environment.GHIDRA_HEADLESS_JAVA_OPTIONS).not.toContain(
|
||||
'"',
|
||||
);
|
||||
if (process.platform !== "win32")
|
||||
expect(
|
||||
(await stat(join(runtimeRoot, "ownership.json"))).mode & 0o777,
|
||||
|
||||
Reference in New Issue
Block a user