Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): bound release-marker reads in crossProcessLock

Yuewei-LLaebd25dd6fff
diff --git a/apps/desktop/src/main/device-link/crossProcessLock.ts b/apps/desktop/src/main/device-link/crossProcessLock.ts
index aa931c8183..8736985b6e 100644
--- a/apps/desktop/src/main/device-link/crossProcessLock.ts
+++ b/apps/desktop/src/main/device-link/crossProcessLock.ts
@@ -991,10 +991,26 @@ async function publishGateReleaseMarker(gate: ReclaimGate): Promise<void> {
}
async function hasValidGateReleaseMarker(gatePath: string): Promise<boolean> {
+ const markerPath = gateReleaseMarkerPath(gatePath);
+ const gateDir = path.dirname(gatePath);
+ let gateRealDir: string;
try {
- const value = JSON.parse(
- await fsp.readFile(gateReleaseMarkerPath(gatePath), 'utf8'),
- ) as unknown;
+ gateRealDir = fsSync.realpathSync(gateDir);
+ } catch {
+ return false;
+ }
+ let bytes: Buffer | null;
+ try {
+ bytes = await readBoundedFileNoFollow(markerPath, 4 * 1024, {
+ containWithin: gateRealDir,
+ nonBlocking: true,
+ });
+ } catch {
+ return false;
+ }
+ if (bytes === null) return false;
+ try {
+ const value = JSON.parse(bytes.toString('utf8')) as unknown;
return Boolean(
value
&& typeof value === 'object'