refactor(native): extract FAT header format switch in Mach-O slice selection (#632)
Replace inline magic comparisons with an exhaustive fatHeaderFormat switch and add a regression test locking in rejection of 32-bit slice payloads inside little-endian containers. Behavior-preserving: the new test passes on the old implementation.
This commit is contained in:
@@ -253,6 +253,14 @@ describe("byte-swapped universal Apple dispatch metadata", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects a 32-bit slice payload inside a little-endian container", () => {
|
||||
const bytes = wrapped(false);
|
||||
bytes.writeUInt32BE(0xfeedface, 256);
|
||||
expect(() => decodeAppleDispatchMetadata(bytes, 100, provenance)).toThrow(
|
||||
"Only little-endian 64-bit Mach-O metadata is supported",
|
||||
);
|
||||
});
|
||||
|
||||
it("checks the full little-endian FAT64 slice extent", () => {
|
||||
const bytes = wrapped(true);
|
||||
bytes.writeBigUInt64LE(0x100000000n, 16);
|
||||
|
||||
Reference in New Issue
Block a user