Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-702: Fixed an exception that occurred when importing Mach-O files that define zero LC_BUILD_VERSION tool entries

Ryan Kurtz7868dbc4f992
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/BuildVersionCommand.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/BuildVersionCommand.java
index 45d8b4b115..fa918132d3 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/BuildVersionCommand.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/BuildVersionCommand.java
@@ -80,8 +80,10 @@ public class BuildVersionCommand extends LoadCommand {
struct.add(DWORD, "minos", null);
struct.add(DWORD, "sdk", null);
struct.add(DWORD, "ntools", null);
- struct.add(new ArrayDataType(buildToolVersionDataType, ntools,
- buildToolVersionDataType.getLength()), "build_tool_version[]", null);
+ if (ntools > 0) {
+ struct.add(new ArrayDataType(buildToolVersionDataType, ntools,
+ buildToolVersionDataType.getLength()), "build_tool_version[]", null);
+ }
struct.setCategoryPath(new CategoryPath(MachConstants.DATA_TYPE_CATEGORY));
return struct;
}