fix(ida): stop the private input of a universal Mach-O at the end of the selected slice (#2291)

* test(ida): expect the private input of a universal Mach-O to end at the selected slice

Cover a universal file larger than one read chunk with another slice after the selected one, for both a middle slice and the first slice.

* fix(ida): stop the private input of a universal Mach-O at the end of the selected slice

A read chunk that starts after the slice produced a negative end offset, and Buffer.subarray counts a negative bound from the end, so the head of the following slice was written to the private input and its digest.
This commit is contained in:
Mykola Dementiev
2026-10-13 14:48:17 +08:00
committed by GitHub
parent 1a1b67c888
commit c6acd19b6d
2 changed files with 96 additions and 3 deletions
+4 -2
View File
@@ -85,8 +85,10 @@ export class IdaWorkspace {
slice === undefined
? position + bytes.length
: Math.min(position + bytes.length, slice.offset + slice.size);
const admitted = bytes.subarray(start - position, end - position);
if (admitted.length > 0) {
// A chunk after the slice has end < position, and a negative subarray
// bound would count from the chunk's end instead of being empty.
if (end > start) {
const admitted = bytes.subarray(start - position, end - position);
inputHash.update(admitted);
await input.write(admitted);
}