mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
GP-3314 corrected zero-length DataComponent issue
This commit is contained in:
parent
f6922713b1
commit
b8fed4fd80
2 changed files with 20 additions and 16 deletions
|
@ -40,7 +40,9 @@ class DataComponent extends DataDB {
|
||||||
private int[] path;
|
private int[] path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new DataComponent
|
* Constructs a new {@link DataComponent} for a {@link DataTypeComponent}.
|
||||||
|
* NOTE: a zero-length component will be forced to have a length of 1-byte.
|
||||||
|
* This can result in what would appear to be overlapping components with the same overset.
|
||||||
* @param codeMgr the code manager.
|
* @param codeMgr the code manager.
|
||||||
* @param componentCache data component cache
|
* @param componentCache data component cache
|
||||||
* @param address the address of the data component
|
* @param address the address of the data component
|
||||||
|
@ -57,29 +59,31 @@ class DataComponent extends DataDB {
|
||||||
this.component = component;
|
this.component = component;
|
||||||
this.level = parent.level + 1;
|
this.level = parent.level + 1;
|
||||||
this.offset = component.getOffset();
|
this.offset = component.getOffset();
|
||||||
this.length = component.getLength();
|
length = component.getLength();
|
||||||
|
if (length == 0) {
|
||||||
|
length = 1; // zero-length components must be forced to have a length of 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new array DataComponent.
|
* Constructs a new {@link DataComponent} for an {@link Array} element.
|
||||||
* @param codeMgr the code manager.
|
* @param codeMgr the code manager.
|
||||||
* @param componentCache data component cache
|
* @param componentCache data component cache
|
||||||
* @param address the address of the data component
|
* @param address the address of the data component
|
||||||
* @param addr the convert address long value
|
* @param addr the convert address long value
|
||||||
* @param parent the DataDB object that contains this component.
|
* @param parent the DataDB object that contains this component.
|
||||||
* @param array the array containing this component.
|
* @param array the array containing this component.
|
||||||
* @param ordinal the ordinal for this component.
|
* @param ordinal the array index for this component.
|
||||||
* @param offset the offset of this component within its parent.
|
|
||||||
* @param length the length of this component.
|
|
||||||
*/
|
*/
|
||||||
DataComponent(CodeManager codeMgr, DBObjectCache<DataDB> componentCache, Address address,
|
DataComponent(CodeManager codeMgr, DBObjectCache<DataDB> componentCache, Address address,
|
||||||
long addr, DataDB parent, Array array, int ordinal, int offset, int length) {
|
long addr, DataDB parent, Array array, int ordinal) {
|
||||||
super(codeMgr, componentCache, ordinal, address, addr, array.getDataType());
|
super(codeMgr, componentCache, ordinal, address, addr, array.getDataType());
|
||||||
|
int elementLength = array.getElementLength();
|
||||||
this.indexInParent = ordinal;
|
this.indexInParent = ordinal;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.offset = offset;
|
this.offset = ordinal * elementLength;
|
||||||
this.level = parent.level + 1;
|
this.level = parent.level + 1;
|
||||||
this.length = length;
|
this.length = elementLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -102,6 +106,9 @@ class DataComponent extends DataDB {
|
||||||
dataType = c.getDataType();
|
dataType = c.getDataType();
|
||||||
offset = component.getOffset();
|
offset = component.getOffset();
|
||||||
length = component.getLength();
|
length = component.getLength();
|
||||||
|
if (length == 0) {
|
||||||
|
length = 1; // zero-length components must be forced to have a length of 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (pdt instanceof Array) {
|
else if (pdt instanceof Array) {
|
||||||
Array a = (Array) pdt;
|
Array a = (Array) pdt;
|
||||||
|
|
|
@ -230,19 +230,16 @@ class DataDB extends CodeUnitDB implements Data {
|
||||||
|
|
||||||
if (baseDataType instanceof Array) {
|
if (baseDataType instanceof Array) {
|
||||||
Array array = (Array) baseDataType;
|
Array array = (Array) baseDataType;
|
||||||
int elementLength = array.getElementLength();
|
Address componentAddr = address.add(index * array.getElementLength());
|
||||||
Address componentAddr = address.add(index * elementLength);
|
|
||||||
return new DataComponent(codeMgr, componentCache, componentAddr,
|
return new DataComponent(codeMgr, componentCache, componentAddr,
|
||||||
addressMap.getKey(componentAddr, false), this, array, index,
|
addressMap.getKey(componentAddr, false), this, array, index);
|
||||||
index * elementLength, elementLength);
|
|
||||||
}
|
}
|
||||||
if (baseDataType instanceof Composite) {
|
if (baseDataType instanceof Composite) {
|
||||||
Composite struct = (Composite) baseDataType;
|
Composite composite = (Composite) baseDataType;
|
||||||
DataTypeComponent dtc = struct.getComponent(index);
|
DataTypeComponent dtc = composite.getComponent(index);
|
||||||
Address componentAddr = address.add(dtc.getOffset());
|
Address componentAddr = address.add(dtc.getOffset());
|
||||||
return new DataComponent(codeMgr, componentCache, componentAddr,
|
return new DataComponent(codeMgr, componentCache, componentAddr,
|
||||||
addressMap.getKey(componentAddr, false), this, dtc);
|
addressMap.getKey(componentAddr, false), this, dtc);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (baseDataType instanceof DynamicDataType) {
|
if (baseDataType instanceof DynamicDataType) {
|
||||||
DynamicDataType ddt = (DynamicDataType) baseDataType;
|
DynamicDataType ddt = (DynamicDataType) baseDataType;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue