mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 12:00:04 +02:00
Merge remote-tracking branch
'origin/GP-3020-dragonmacher-fill-in-structure-size-limit' into patch (Closes #4879)
This commit is contained in:
commit
e12837fe7b
1 changed files with 9 additions and 5 deletions
|
@ -559,12 +559,16 @@ public class FillOutStructureCmd extends BackgroundCommand {
|
|||
return currentProgram.getDataTypeManager().getUniqueName(new CategoryPath(category), base);
|
||||
}
|
||||
|
||||
private boolean sanityCheck(long offset) {
|
||||
private boolean sanityCheck(long offset, long existingSize) {
|
||||
|
||||
if (offset < 0) {
|
||||
return false; // offsets shouldn't be negative
|
||||
}
|
||||
if (offset < existingSize) {
|
||||
return true; // we have room in the structure
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@ -648,7 +652,7 @@ public class FillOutStructureCmd extends BackgroundCommand {
|
|||
long value = getSigned(inputs[1]);
|
||||
newOff = currentRef.offset +
|
||||
((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);
|
||||
// Don't do componentMap.addDataType() as data-type info here is likely uninformed
|
||||
componentMap.setMinimumSize(newOff);
|
||||
|
@ -659,7 +663,7 @@ public class FillOutStructureCmd extends BackgroundCommand {
|
|||
break;
|
||||
}
|
||||
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);
|
||||
// Don't do componentMap.addReference() as data-type info here is likely uninformed
|
||||
componentMap.setMinimumSize(newOff);
|
||||
|
@ -670,7 +674,7 @@ public class FillOutStructureCmd extends BackgroundCommand {
|
|||
break;
|
||||
}
|
||||
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);
|
||||
// Don't do componentMap.addReference() as data-type info here is likely uninformed
|
||||
componentMap.setMinimumSize(subOff);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue