Ghidra is a software reverse engineering (SRE) framework
Some bug fixes for ptr arith
caheckman5332624de8a7
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.ccindex 4f5e7e1d6d..9a765268b9 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc@@ -5928,9 +5928,16 @@ bool AddTreeState::apply(void)preventDistribution = true;spanAddTree(baseOp,1);}+ calcSubtype();+ }+ if (!valid) {+ // Distribution transforms were made+ ostringstream s;+ s << "Problems distributing in pointer arithmetic at ";+ baseOp->getAddr().printRaw(s);+ data.warningHeader(s.str());+ return true;}- if (!valid)- throw LowlevelError("Problems distributing in ptrarith");buildTree();return true;}diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.ccindex 612b6b7709..3b92b682c0 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc@@ -1939,10 +1939,14 @@ Datatype *TypeFactory::downChain(Datatype *ptrtype,uintb &off)if (ptrtype->metatype != TYPE_PTR) return (Datatype *)0;TypePointer *ptype = (TypePointer *)ptrtype;Datatype *pt = ptype->ptrto;+ // If we know we have exactly one of an array, strip the array to get pointer to element+ bool doStrip = (pt->getMetatype() != TYPE_ARRAY);pt = pt->getSubType(off,&off);if (pt == (Datatype *)0)return (Datatype *)0;- return getTypePointerStripArray(ptype->size,pt,ptype->getWordSize());+ if (doStrip)+ return getTypePointerStripArray(ptype->size, pt, ptype->getWordSize());+ return getTypePointer(ptype->size,pt,ptype->getWordSize());}/// The data-type propagation system can push around data-types that are \e partial or are