Skip to content

Commit

Permalink
Test read error condition
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderOMara committed Jan 20, 2025
1 parent 8aa230d commit 409a1c9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions macho/universal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,28 @@ Deno.test('open suspicious gap', async () => {
assertEquals(uni.isSuspicious(), true);
});

Deno.test('open suspicious read error', async () => {
const data = new ArrayBuffer(512 + 1);
const header = new FatHeader(data);
header.magic = FAT_MAGIC;
header.nfatArch = 2;

const arch1 = new FatArch(data, header.byteLength);
arch1.offset = 256;
arch1.size = 256 + 1;
arch1.align = 8;

const arch2 = new FatArch(data, header.byteLength + arch1.byteLength);
arch2.offset = 256 * 3;
arch2.size = 256;
arch2.align = 8;

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 409a1c9

Please sign in to comment.