refactor(macho): read LC_BUILD_VERSION fields through BinaryReader

The build-version platform and tool count were read through a local
DataView after the command-size check. Read them with machoWordReader,
as the other load-command decoders do, and drop the now-unused viewOf.

Refs #11865

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
gensokyo-devandgensokyo-dev authored and Ysopwnable committed 2026-11-21 19:52:16 +01:00
1 parent add4faf2ad
commit a0d2357230
2 files changed
+3 -7

No files matched your search

@@ -1,5 +1,4 @@
{
"src/domain/apple/machoLoadCommandReader.ts": 2,
"src/domain/desktop/openPgpKeys.ts": 2,
"src/domain/managed/managedMetadataInventoryRows.ts": 2,
"src/native/AppleDispatchMetadata.ts": 1,
+3 -6
View File
@@ -754,14 +754,14 @@ const decodeCommand = (
"malformed",
`load command ${index} is too short for LC_BUILD_VERSION`,
);
const view = viewOf(body);
const toolCount = view.getUint32(20, true);
const reader = machoWordReader(body, true);
const toolCount = reader.u32(20);
if (toolCount > Math.floor((body.byteLength - 24) / 8))
throw machoIssue(
"malformed",
`load command ${index} LC_BUILD_VERSION tool records exceed cmdsize`,
);
const platform = view.getUint32(8, true);
const platform = reader.u32(8);
slice.platforms.push(platform);
return;
}
@@ -1141,6 +1141,3 @@ const fileTypeName = (fileType: number): MachoSlice["file_type"] =>
const version = (value: number): string =>
`${value >>> 16}.${(value >>> 8) & 0xff}.${value & 0xff}`;
const viewOf = (bytes: Uint8Array): DataView =>
new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);