Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-2477_James_prevent_large_scalar_conversions

Jamese8bda10bc18f
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ConvertConstantAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ConvertConstantAction.java
index 84d7e89818..dbbd98eabb 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ConvertConstantAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ConvertConstantAction.java
@@ -51,6 +51,8 @@ public abstract class ConvertConstantAction extends AbstractDecompilerAction {
* that corresponds with the selected constant in the decompiler window.
*/
private final static int MAX_INSTRUCTION_WINDOW = 20;
+
+ private static final int MAX_SCALAR_SIZE = 8;
protected DecompilePlugin plugin;
private FontMetrics metrics = null;
private int convertType; // The EquateSymbol conversion type performed by the action
@@ -209,7 +211,7 @@ public abstract class ConvertConstantAction extends AbstractDecompilerAction {
return null;
}
Varnode convertVn = tokenAtCursor.getVarnode();
- if (convertVn == null || !convertVn.isConstant()) {
+ if (convertVn == null || !convertVn.isConstant() || convertVn.getSize() > MAX_SCALAR_SIZE) {
return null;
}
HighSymbol symbol = convertVn.getHigh().getSymbol();