mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-01-10 14:38:02 -05:00
Merge remote-tracking branch
'origin/GP-1957_ghidra1_IncorrectPointerShiftSettingCheck' (Closes #4179)
This commit is contained in:
@@ -35,7 +35,7 @@ public class OffsetMaskSettingsDefinition
|
||||
private static final String DISPLAY_NAME = "Offset Mask";
|
||||
private static BigInteger MAX_VALUE = new BigInteger("0ffffffffffffffff", 16);
|
||||
|
||||
private static final long DEFAULT = -1; // unsigned mask - all bits are ones
|
||||
public static final long DEFAULT = -1; // unsigned mask - all bits are ones
|
||||
|
||||
public static final OffsetMaskSettingsDefinition DEF =
|
||||
new OffsetMaskSettingsDefinition();
|
||||
|
||||
@@ -411,7 +411,11 @@ public class PointerDataType extends BuiltIn implements Pointer {
|
||||
long addrOffset = offset;
|
||||
|
||||
long mask = OffsetMaskSettingsDefinition.DEF.getValue(settings);
|
||||
if (mask != 0) {
|
||||
if (mask == 0) {
|
||||
errorHandler.accept("Invalid pointer mask: 0");
|
||||
return null;
|
||||
}
|
||||
if (mask != OffsetMaskSettingsDefinition.DEFAULT) {
|
||||
addrOffset &= mask;
|
||||
}
|
||||
|
||||
@@ -424,7 +428,7 @@ public class PointerDataType extends BuiltIn implements Pointer {
|
||||
addrOffset >>>= -shift; // unsigned right-shift
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if (shift > 0) {
|
||||
addrOffset <<= shift; // left-shift
|
||||
}
|
||||
|
||||
@@ -504,7 +508,7 @@ public class PointerDataType extends BuiltIn implements Pointer {
|
||||
errorHandler.accept("Unsupported segmented address size: " + size);
|
||||
return null;
|
||||
}
|
||||
if (mask != 0 || shift != 0) {
|
||||
if (mask != OffsetMaskSettingsDefinition.DEFAULT || shift != 0) {
|
||||
errorHandler.accept("Unsupported mask/shift setting for segmented address");
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user