From a574b744b8fe95e906524684f6a3b28cdc656499 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Tue, 6 Oct 2026 02:21:03 +0800 Subject: [PATCH] fix(ghidra): avoid nested quotes in Windows Java options --- src/ghidra/GhidraLauncher.ts | 8 ++++---- tests/boundary/providers/ghidra/ghidraLauncher.test.ts | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ghidra/GhidraLauncher.ts b/src/ghidra/GhidraLauncher.ts index cd4b3cdc5..c0f6e349a 100644 --- a/src/ghidra/GhidraLauncher.ts +++ b/src/ghidra/GhidraLauncher.ts @@ -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, diff --git a/tests/boundary/providers/ghidra/ghidraLauncher.test.ts b/tests/boundary/providers/ghidra/ghidraLauncher.test.ts index 4cf5ad5ef..3157c025d 100644 --- a/tests/boundary/providers/ghidra/ghidraLauncher.test.ts +++ b/tests/boundary/providers/ghidra/ghidraLauncher.test.ts @@ -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,