fix(artifacts): defer lazy loads and tighten Mach-O validation
Address review findings in trace_dylib_resolution: - Resolve LC_LAZY_LOAD_DYLIB dependencies without traversing them, since dyld loads them on first use. An unresolved one becomes `lazy-load-unresolved`, not a launch failure. - Accept FAT tables up to 128 records, as target opening does. A table that names no Mach-O CPU type, such as a Java class file, is not Mach-O. - Require 8-byte load-command alignment in 64-bit images. 1,508 real slices still match otool. - Report EACCES/EPERM while probing, reading, or hashing as an `unavailable` failure naming the code and path, rather than generic io. Findings and limitations move to dylibResolutionFindings.ts to keep the resolver under the module size limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a0ec3e2016
commit
91280393cd
@@ -210,6 +210,35 @@ describe("Mach-O load command reader failures", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("requires 8-byte command alignment in 64-bit images", async () => {
|
||||
const command = new Uint8Array(12);
|
||||
const view = new DataView(command.buffer);
|
||||
view.setUint32(0, LC.CODE_SIGNATURE, true);
|
||||
view.setUint32(4, 12, true);
|
||||
expect(await read(machoImage({ commands: [command] }))).toMatchObject({
|
||||
status: "malformed",
|
||||
reason: expect.stringContaining("invalid cmdsize 12"),
|
||||
});
|
||||
expect(
|
||||
await read(
|
||||
machoImage({
|
||||
cpu: { type: 7, subtype: 3 },
|
||||
wide: false,
|
||||
commands: [command],
|
||||
}),
|
||||
),
|
||||
).toMatchObject({ status: "parsed" });
|
||||
});
|
||||
|
||||
it("accepts FAT tables up to 128 records that name a Mach-O CPU", async () => {
|
||||
const slices = Array.from({ length: 24 }, () => ({
|
||||
cpu: CPU.arm64,
|
||||
bytes: machoImage({}),
|
||||
}));
|
||||
const facts = await read(fatImage(slices));
|
||||
expect(facts.status === "parsed" && facts.slices).toHaveLength(24);
|
||||
});
|
||||
|
||||
it("rejects string commands too short to hold their string offset", async () => {
|
||||
const short = new Uint8Array(8);
|
||||
const view = new DataView(short.buffer);
|
||||
|
||||
Reference in New Issue
Block a user