fix(apple): validate complete image mappings with indexed VM lookup

This commit is contained in:
morluto
2026-10-08 21:13:43 +08:00
parent b23f8288b4
commit d39543145e
2 changed files with 53 additions and 11 deletions
@@ -54,6 +54,20 @@ const dylib = (installName: string, dependencies: readonly Uint8Array[] = []) =>
commands: [dylibCommand(LC.ID_DYLIB, installName), ...dependencies],
});
it("rejects unmapped images when no unavailable subcache can explain the address", async () => {
const fixture = dyldCacheFixture(IMAGES);
const main = Buffer.from(fixture.main);
main.writeBigUInt64LE(0x700000000n, main.readUInt32LE(0x1c0));
const path = await writeCache({ ...fixture, main });
expect(await inspectDyldSharedCache({ cache_path: path })).toMatchObject({
ok: false,
error: {
reason: "format",
detail: expect.stringContaining("unmapped image address"),
},
});
});
const writeCache = async (
fixture: CacheFixture,
name = "dyld_shared_cache_arm64e",