Ghidra is a software reverse engineering (SRE) framework
GT-3032 exclude flexible array component from list of components passed to structure packer
ghidra18c689a009920
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedComponentPacker.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedComponentPacker.javaindex c8d5241fe3..2aa9e1d85f 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedComponentPacker.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedComponentPacker.java@@ -59,8 +59,7 @@ class AlignedComponentPacker {* @param isLastComponent true if dtc is the last component within the structure*/void addComponent(InternalDataTypeComponent dtc, boolean isLastComponent) {- if (dtc.getDataType() == DataType.DEFAULT ||- (dtc.isFlexibleArrayComponent() && !isLastComponent)) {+ if (dtc.getDataType() == DataType.DEFAULT || dtc.isFlexibleArrayComponent()) {throw new IllegalArgumentException("unsupported component");}if (!packComponent(dtc)) {diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedStructureInspector.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedStructureInspector.javaindex 9b9a11f04b..71d8178b12 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedStructureInspector.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedStructureInspector.java@@ -26,7 +26,8 @@ import ghidra.util.exception.DuplicateNameException;/*** <code>AlignedStructureInspector</code> provides a simple instance of a structure* member container used to perform alignment operations without forcing modification- * of the actual structure.+ * of the actual structure. A wrapper is not used for the flexible array component+ * which will not be modified by packer.*/public class AlignedStructureInspector extends AlignedStructurePacker {@@ -39,9 +40,6 @@ public class AlignedStructureInspector extends AlignedStructurePacker {for (DataTypeComponent c : structure.getComponents()) {list.add(new ReadOnlyComponentWrapper(c));}- if (structure.hasFlexibleArrayComponent()) {- list.add(new ReadOnlyComponentWrapper(structure.getFlexibleArrayComponent()));- }return list;}