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): realpath legacy dir before bounded manifest read

Yuewei-LLf12904fd5d15
diff --git a/apps/desktop/src/main/ownerNamespaceMigration.ts b/apps/desktop/src/main/ownerNamespaceMigration.ts
index d42bcea231..b76d6fb6c9 100644
--- a/apps/desktop/src/main/ownerNamespaceMigration.ts
+++ b/apps/desktop/src/main/ownerNamespaceMigration.ts
@@ -825,10 +825,19 @@ function readLegacyGhostManifest(
expectedId: string,
): LegacyGhostManifestRead {
const manifestPath = path.join(dir, GHOST_MANIFEST_FILE);
+ // containWithin needs the real path so that symlinked/relocated userData
+ // doesn't reject the manifest as outside the root. If realpathSync itself
+ // fails the directory is inaccessible and the scan treats it as invalid.
+ let containWithin: string;
+ try {
+ containWithin = fsSync.realpathSync(dir);
+ } catch {
+ return { kind: 'invalid' };
+ }
let bytes: Buffer | null;
try {
bytes = readBoundedFileNoFollowSync(manifestPath, GHOST_MANIFEST_MAX_BYTES, {
- containWithin: dir,
+ containWithin,
});
} catch (error) {
return isMissing(error) ? { kind: 'invalid' } : { kind: 'deferred' };