fix(apple): validate build-version tool records within cmdsize (#1784)

This commit is contained in:
Ysopwnable
2026-10-11 17:50:56 +08:00
committed by GitHub
parent 85ccef34de
commit 817aef4068
2 changed files with 73 additions and 1 deletions
@@ -414,7 +414,14 @@ const decodeCommand = (
"malformed",
`load command ${index} is too short for LC_BUILD_VERSION`,
);
const platform = viewOf(body).getUint32(8, true);
const view = viewOf(body);
const toolCount = view.getUint32(20, true);
if (toolCount > Math.floor((body.byteLength - 24) / 8))
throw new MachoFormatIssue(
"malformed",
`load command ${index} LC_BUILD_VERSION tool records exceed cmdsize`,
);
const platform = view.getUint32(8, true);
slice.platforms.push(platform);
return;
}