mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
Merge remote-tracking branch
'origin/GP-3020-dragonmacher-fill-in-structure-size-limit' into patch (Closes #4879)
This commit is contained in:
@@ -559,12 +559,16 @@ public class FillOutStructureCmd extends BackgroundCommand {
|
|||||||
return currentProgram.getDataTypeManager().getUniqueName(new CategoryPath(category), base);
|
return currentProgram.getDataTypeManager().getUniqueName(new CategoryPath(category), base);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean sanityCheck(long offset) {
|
private boolean sanityCheck(long offset, long existingSize) {
|
||||||
|
|
||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
return false; // offsets shouldn't be negative
|
return false; // offsets shouldn't be negative
|
||||||
}
|
}
|
||||||
|
if (offset < existingSize) {
|
||||||
|
return true; // we have room in the structure
|
||||||
|
}
|
||||||
if (offset > 0x1000) {
|
if (offset > 0x1000) {
|
||||||
return false; // Arbitrary size cut-off to prevent creating huge structures
|
return false; // bigger than existing size; arbitrary cut-off to prevent huge structures
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -648,7 +652,7 @@ public class FillOutStructureCmd extends BackgroundCommand {
|
|||||||
long value = getSigned(inputs[1]);
|
long value = getSigned(inputs[1]);
|
||||||
newOff = currentRef.offset +
|
newOff = currentRef.offset +
|
||||||
((pcodeOp.getOpcode() == PcodeOp.INT_ADD) ? value : (-value));
|
((pcodeOp.getOpcode() == PcodeOp.INT_ADD) ? value : (-value));
|
||||||
if (sanityCheck(newOff)) { // should this offset create a location in the structure?
|
if (sanityCheck(newOff, componentMap.getSize())) { // should this offset create a location in the structure?
|
||||||
putOnList(output, newOff, todoList, doneList);
|
putOnList(output, newOff, todoList, doneList);
|
||||||
// Don't do componentMap.addDataType() as data-type info here is likely uninformed
|
// Don't do componentMap.addDataType() as data-type info here is likely uninformed
|
||||||
componentMap.setMinimumSize(newOff);
|
componentMap.setMinimumSize(newOff);
|
||||||
@@ -659,7 +663,7 @@ public class FillOutStructureCmd extends BackgroundCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
newOff = currentRef.offset + getSigned(inputs[1]) * inputs[2].getOffset();
|
newOff = currentRef.offset + getSigned(inputs[1]) * inputs[2].getOffset();
|
||||||
if (sanityCheck(newOff)) { // should this offset create a location in the structure?
|
if (sanityCheck(newOff, componentMap.getSize())) { // should this offset create a location in the structure?
|
||||||
putOnList(output, newOff, todoList, doneList);
|
putOnList(output, newOff, todoList, doneList);
|
||||||
// Don't do componentMap.addReference() as data-type info here is likely uninformed
|
// Don't do componentMap.addReference() as data-type info here is likely uninformed
|
||||||
componentMap.setMinimumSize(newOff);
|
componentMap.setMinimumSize(newOff);
|
||||||
@@ -670,7 +674,7 @@ public class FillOutStructureCmd extends BackgroundCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
long subOff = currentRef.offset + getSigned(inputs[1]);
|
long subOff = currentRef.offset + getSigned(inputs[1]);
|
||||||
if (sanityCheck(subOff)) { // should this offset create a location in the structure?
|
if (sanityCheck(subOff, componentMap.getSize())) { // should this offset create a location in the structure?
|
||||||
putOnList(output, subOff, todoList, doneList);
|
putOnList(output, subOff, todoList, doneList);
|
||||||
// Don't do componentMap.addReference() as data-type info here is likely uninformed
|
// Don't do componentMap.addReference() as data-type info here is likely uninformed
|
||||||
componentMap.setMinimumSize(subOff);
|
componentMap.setMinimumSize(subOff);
|
||||||
|
|||||||
Reference in New Issue
Block a user