Ghidra is a software reverse engineering (SRE) framework
tests passing
caheckmane5c7b583050b
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/heritage.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/heritage.ccindex 4317436fb6..c7abdf43dd 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/heritage.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/heritage.cc@@ -631,6 +631,11 @@ void LoadGuard::finalizeRange(const ValueSetRead &valueSet)analysisState = 1; // In all cases the settings determined here are finalconst CircleRange &range( valueSet.getRange() );uintb rangeSize = range.getSize();+ if (rangeSize == 0x100 || rangeSize == 0x10000) {+ // These sizes likely result from the storage size of the index+ if (step == 0) // If we didn't see signs of iteration+ rangeSize = 0; // don't use this range+ }if (rangeSize > 1 && rangeSize < 0xffffff) { // Did we converge to something reasonableanalysisState = 2; // Mark that we got a definitive resultif (rangeSize > 2)diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/rangeutil.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/rangeutil.ccindex c79348d624..cf86fb98eb 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/rangeutil.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/rangeutil.cc@@ -1098,8 +1098,8 @@ bool CircleRange::pushForwardUnary(OpCode opc,const CircleRange &in1,int4 inSizeleft = in1.left;right = (in1.right - in1.step) & in1.mask;if (right < left) { // Extending causes 2 pieces- left = 0;- right = in1.mask;+ left = left % step;+ right = in1.mask + 1 + left;}else {right += step; // Impossible for it to wrap with bigger mask@@ -1112,9 +1112,10 @@ bool CircleRange::pushForwardUnary(OpCode opc,const CircleRange &in1,int4 inSizeleft = sign_extend(in1.left, inSize, outSize);right = sign_extend((in1.right - in1.step)&in1.mask, inSize, outSize);if ((intb)right < (intb)left) {- right = calc_mask(inSize);- left = calc_mask(outSize) ^ right;- right += 1;+ uintb rem = left % step;+ right = calc_mask(inSize) >> 1;+ left = (calc_mask(outSize) ^ right) + rem;+ right = right + 1 + rem;}elseright += step;