fix(ghidra): bound Swift literal reads and compare decoded strings
Large immortal literals are measured against the remaining heap before allocation, and a failed fit stays visible as a limitation. The canonical empty string is kept. Small and large literals now require matching address nullability, and function comparison treats decoded literals as string evidence without equating a missing record to an empty one.
This commit is contained in:
@@ -139,6 +139,18 @@ const compareStringsAndNames = (
|
||||
right: FunctionSnapshot,
|
||||
context: ComparisonContext,
|
||||
): FunctionDimension => {
|
||||
const leftRecorded = left.dossier.swift_string_literals !== undefined;
|
||||
const rightRecorded = right.dossier.swift_string_literals !== undefined;
|
||||
if (leftRecorded !== rightRecorded)
|
||||
return unresolvedDimension({
|
||||
dimension: "strings_names",
|
||||
links: context.links,
|
||||
leftCount: recordedStringFactCount(left),
|
||||
rightCount: recordedStringFactCount(right),
|
||||
limitations: [
|
||||
"Swift String literal coverage differs; one dossier did not record decoded literals.",
|
||||
],
|
||||
});
|
||||
const leftValues = stringAndNameProjection(left);
|
||||
const rightValues = stringAndNameProjection(right);
|
||||
if (leftValues === null || rightValues === null)
|
||||
@@ -154,6 +166,13 @@ const compareStringsAndNames = (
|
||||
return compareValues("strings_names", leftValues, rightValues, context);
|
||||
};
|
||||
|
||||
const recordedStringFactCount = (snapshot: FunctionSnapshot): number | null =>
|
||||
snapshot.dossier.swift_string_literals === undefined
|
||||
? null
|
||||
: snapshot.dossier.referenced_strings.length +
|
||||
snapshot.dossier.referenced_names.length +
|
||||
snapshot.dossier.swift_string_literals.length;
|
||||
|
||||
const compareReferences = (
|
||||
left: FunctionSnapshot,
|
||||
right: FunctionSnapshot,
|
||||
|
||||
Reference in New Issue
Block a user