GP-4457: The dyld_shared_cache loader no longer throws an exception when

importing newer versions that use dyld_cache_slide_info5
This commit is contained in:
Ryan Kurtz
2024-03-25 08:05:47 -04:00
parent 914d3ef326
commit 2aea201406
3 changed files with 8 additions and 5 deletions
@@ -408,7 +408,9 @@ public class DyldCacheHeader implements StructConverter {
DyldCacheSlideInfoCommon slideInfo = DyldCacheSlideInfoCommon.parseSlideInfo(reader,
info.getSlideInfoFileOffset(), info.getAddress(), info.getSize(),
info.getFileOffset(), log, monitor);
slideInfoList.add(slideInfo);
if (slideInfo != null) {
slideInfoList.add(slideInfo);
}
}
}
}
@@ -113,7 +113,7 @@ public class DyldCacheSlideInfo4 extends DyldCacheSlideInfoCommon {
}
/**
* Create a new {@link DyldCacheSlideInfo3}.
* Create a new {@link DyldCacheSlideInfo4}.
*
* @param reader A {@link BinaryReader} positioned at the start of a DYLD slide info 3
* @param mappingAddress The base address of where the slide fixups will take place
@@ -67,9 +67,11 @@ public abstract class DyldCacheSlideInfoCommon implements StructConverter {
monitor.setMessage("Parsing DYLD slide info...");
monitor.initialize(1);
String errorMessage = "Failed to parse dyld_cache_slide_info";
try {
reader.setPointerIndex(slideInfoOffset);
int version = reader.readInt(reader.getPointerIndex());
errorMessage += version;
DyldCacheSlideInfoCommon returnedSlideInfo = switch (version) {
case 1 -> new DyldCacheSlideInfo1(reader, mappingAddress, mappingSize,
mappingFileOffset);
@@ -79,15 +81,14 @@ public abstract class DyldCacheSlideInfoCommon implements StructConverter {
mappingFileOffset);
case 4 -> new DyldCacheSlideInfo4(reader, mappingAddress, mappingSize,
mappingFileOffset);
default -> throw new IOException("Unrecognized slide info version: " + version);
default -> throw new IOException(); // will be caught and version will be added to message
};
monitor.incrementProgress(1);
returnedSlideInfo.slideInfoOffset = slideInfoOffset;
return returnedSlideInfo;
}
catch (IOException e) {
log.appendMsg(DyldCacheSlideInfoCommon.class.getSimpleName(),
"Failed to parse dyld_cache_slide_info.");
log.appendMsg(DyldCacheSlideInfoCommon.class.getSimpleName(), errorMessage);
return null;
}
}