fix(native): reject trailing text in lipo integers and keep multi-word otool keys (#531)
This commit is contained in:
@@ -42,3 +42,13 @@ it("does not reinterpret segment and section flags as Mach header flags", async
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps multi-word field names such as time stamp intact", async () => {
|
||||
const load = parseOtoolLoadCommands(await nativeFixture("otool-load.txt"));
|
||||
const stamped = load.commands.filter(
|
||||
(command) => "time stamp" in command.fields,
|
||||
);
|
||||
expect(stamped.length).toBeGreaterThan(0);
|
||||
expect(load.commands.some((command) => "time" in command.fields)).toBe(false);
|
||||
expect(stamped[0]?.fields["time stamp"]).toMatch(/^2 Thu Jan/);
|
||||
});
|
||||
|
||||
@@ -305,6 +305,20 @@ describe("native macOS provider failures and parsing", () => {
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects trailing text in lipo numeric fields instead of truncating", () => {
|
||||
const output = [
|
||||
"architecture arm64",
|
||||
" cputype CPU_TYPE_ARM64",
|
||||
" cpusubtype CPU_SUBTYPE_ARM64_ALL",
|
||||
" offset 16384 trailing-junk",
|
||||
" size 0x10",
|
||||
" align 2^14 (16384)",
|
||||
].join("\n");
|
||||
expect(parseLipoArchitectures(output)).toMatchObject([
|
||||
{ name: "arm64", file_offset: null, size: null, alignment: 16384 },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
class FailingRunner implements NativeCommandRunner {
|
||||
|
||||
Reference in New Issue
Block a user