mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 14:35:45 +00:00
fix(macho): require bounded slice evidence when JVM identity is unresolved (#12482)
This commit is contained in:
1 parent
93f4c3749f
commit
adafb97eb1
4 files changed
+131
-46
No files matched your search
@@ -118,6 +118,7 @@ import {
|
||||
import {
|
||||
classifyFatContainerIdentity,
|
||||
readFatContainerHeader,
|
||||
readFatJvmIdentityLimitIssue,
|
||||
readMachoHeaderPrefixFacts,
|
||||
type FatSliceHeaderEvidence,
|
||||
type MachoHeaderPrefixFacts,
|
||||
@@ -126,7 +127,6 @@ import {
|
||||
hasJvmClassHeader,
|
||||
isJvmClassFile,
|
||||
MAX_JVM_CLASS_IDENTITY_BYTES,
|
||||
JVM_CLASS_IDENTITY_LIMIT_REASON,
|
||||
} from "../domain/apple/jvmClassFile.js";
|
||||
import {
|
||||
MachoLoadCommandCursor,
|
||||
@@ -1062,13 +1062,20 @@ const readExecutableMetadata = async (
|
||||
if (
|
||||
mayBeJvmClass &&
|
||||
fileSize > MAX_JVM_CLASS_IDENTITY_BYTES &&
|
||||
fatEvidence !== undefined &&
|
||||
classifyFatContainerIdentity(
|
||||
fatEvidence.header,
|
||||
(offset) => fatEvidence.sliceHeadersByOffset.get(offset)?.magic,
|
||||
).state === "malformed"
|
||||
)
|
||||
return err(JVM_CLASS_IDENTITY_LIMIT_REASON);
|
||||
fatEvidence !== undefined
|
||||
) {
|
||||
const { header, sliceHeadersByOffset } = fatEvidence;
|
||||
const identity = classifyFatContainerIdentity(
|
||||
header,
|
||||
(offset) => sliceHeadersByOffset.get(offset)?.magic,
|
||||
);
|
||||
const limitIssue = await readFatJvmIdentityLimitIssue(
|
||||
header,
|
||||
identity,
|
||||
(offset, length) => readHandleRange(handle, offset, length, signal),
|
||||
);
|
||||
if (limitIssue !== null) return err(limitIssue);
|
||||
}
|
||||
const parsed = parseExecutableHeader(
|
||||
bytes,
|
||||
hostArchitecture,
|
||||
@@ -1338,13 +1345,7 @@ const readFatSliceHeaderEvidence = async (
|
||||
for (let index = 0; index < header.slices.length; index += 1) {
|
||||
const slice = header.slices[index];
|
||||
if (slice === undefined) continue;
|
||||
if (header.rangeIssues[index] !== null) {
|
||||
sliceHeadersByOffset.set(
|
||||
slice.offset,
|
||||
readMachoHeaderPrefixFacts(Buffer.alloc(0)),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (header.rangeIssues[index] !== null) continue;
|
||||
const observedLength = Math.min(12, slice.size);
|
||||
const thinHeader = await readHandleRange(
|
||||
handle,
|
||||
|
||||
Reference in new issue
Block a user