Skip to content

Commit

Permalink
Test suspicious non-zero gap
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderOMara committed Jan 20, 2025
1 parent 5c9c54f commit 8aa230d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions macho/universal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,24 @@ Deno.test('open duplicate offset', async () => {
);
});

Deno.test('open suspicious gap', async () => {
const data = new ArrayBuffer(1024);
const header = new FatHeader(data);
header.magic = FAT_MAGIC;
header.nfatArch = 1;

const arch = new FatArch(data, header.byteLength);
arch.offset = 512;
arch.size = 512;

new Uint8Array(data)[256] = 1;

const blob = new Blob([data]);
const uni = new Universal();
await uni.open(blob);
assertEquals(uni.isSuspicious(), true);
});

Deno.test('typeOf under header', async () => {
const blob = new Blob([new ArrayBuffer(MachHeader.BYTE_LENGTH - 1)]);
assertEquals(await Universal.typeOf(blob), 0);
Expand Down

0 comments on commit 8aa230d

Please sign in to comment.