Skip to content

Ghidra is a software reverse engineering (SRE) framework

Adding in checks to prevent the parsing of structures that don't exist.

Ryan Kurtz40fc12eddb45
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheHeader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheHeader.java
index a8f9463940..76be13439b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheHeader.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheHeader.java
@@ -378,6 +378,9 @@ public class DyldCacheHeader implements StructConverter {
}
private void parseImageInfo(MessageLog log, TaskMonitor monitor) throws CancelledException {
+ if (imagesOffset == 0) {
+ return;
+ }
monitor.setMessage("Parsing DYLD image info...");
monitor.initialize(imagesCount);
try {
@@ -395,6 +398,9 @@ public class DyldCacheHeader implements StructConverter {
}
private void parseSlideInfo(MessageLog log, TaskMonitor monitor) throws CancelledException {
+ if (slideInfoOffset == 0) {
+ return;
+ }
monitor.setMessage("Parsing DYLD slide info...");
monitor.initialize(1);
try {
@@ -424,6 +430,9 @@ public class DyldCacheHeader implements StructConverter {
private void parseLocalSymbolsInfo(MessageLog log, TaskMonitor monitor)
throws CancelledException {
+ if (localSymbolsOffset == 0) {
+ return;
+ }
monitor.setMessage("Parsing DYLD local symbols info...");
monitor.initialize(1);
try {
@@ -439,6 +448,9 @@ public class DyldCacheHeader implements StructConverter {
}
private void parseBranchPools(MessageLog log, TaskMonitor monitor) throws CancelledException {
+ if (branchPoolsOffset == 0) {
+ return;
+ }
monitor.setMessage("Parsing DYLD branch pool addresses...");
monitor.initialize(branchPoolsCount);
try {
@@ -455,6 +467,9 @@ public class DyldCacheHeader implements StructConverter {
}
private void parseImageTextInfo(MessageLog log, TaskMonitor monitor) throws CancelledException {
+ if (imagesTextOffset == 0) {
+ return;
+ }
monitor.setMessage("Parsing DYLD image text info...");
monitor.initialize(imagesTextCount);
try {
@@ -473,6 +488,9 @@ public class DyldCacheHeader implements StructConverter {
private void parseAcceleratorInfo(Program program, AddressSpace space, MessageLog log,
TaskMonitor monitor) throws CancelledException {
+ if (accelerateInfoAddr == 0) {
+ return;
+ }
monitor.setMessage("Parsing DYLD accelerateor info...");
monitor.initialize(imagesTextCount);
try {
@@ -605,7 +623,7 @@ public class DyldCacheHeader implements StructConverter {
monitor.initialize(branchPoolList.size());
try {
Address addr = fileOffsetToAddr(branchPoolsOffset, program, space);
- for (int i = 0; i < branchPoolList.size(); i++) {
+ for (Long element : branchPoolList) {
Data d = DataUtilities.createData(program, addr, Pointer64DataType.dataType,
Pointer64DataType.dataType.getLength(), false,
DataUtilities.ClearDataMode.CHECK_FOR_SPACE);