GP-4913 / GP-5198 Correct Function StorageEditor issues

This commit is contained in:
ghidra1 2025-01-10 12:31:29 -05:00
parent 2c4882c16a
commit b8afbf7d8b
5 changed files with 115 additions and 68 deletions

View file

@ -181,7 +181,7 @@ public class VariableStorage implements Comparable<VariableStorage> {
return size;
}
private void checkVarnodes() throws InvalidInputException {
private void checkVarnodes() throws IllegalArgumentException, InvalidInputException {
if (varnodes.length == 0) {
throw new IllegalArgumentException("A minimum of one varnode must be specified");
}
@ -191,10 +191,11 @@ public class VariableStorage implements Comparable<VariableStorage> {
for (int i = 0; i < varnodes.length; i++) {
Varnode varnode = varnodes[i];
if (varnode == null) {
throw new InvalidInputException("Null varnode not permitted");
throw new IllegalArgumentException("Null varnode not permitted");
}
if (varnode.getSize() <= 0) {
throw new InvalidInputException("Unsupported varnode size: " + varnode.getSize());
throw new IllegalArgumentException(
"Unsupported varnode size: " + varnode.getSize());
}
boolean isRegister = false;
@ -246,13 +247,13 @@ public class VariableStorage implements Comparable<VariableStorage> {
if (programArch.getLanguage().isBigEndian()) {
if (i < (varnodes.length - 1) && !isRegister) {
throw new InvalidInputException(
"Compound storage must use registers except for least significant varnode");
"Compound storage must use registers except for last BE varnode");
}
}
else {
if (i > 0 && !isRegister) {
throw new InvalidInputException(
"Compound storage must use registers except for most significant varnode");
"Compound storage must use registers except for first LE varnode");
}
}
size += varnode.getSize();
@ -260,7 +261,7 @@ public class VariableStorage implements Comparable<VariableStorage> {
for (int i = 0; i < varnodes.length; i++) {
for (int j = i + 1; j < varnodes.length; j++) {
if (varnodes[i].intersects(varnodes[j])) {
throw new InvalidInputException("One or more conflicting varnodes");
throw new InvalidInputException("One or more conflicting storage varnodes");
}
}
}