GP-2654 Varnodes overlapping multiple structure fields can reconcile

This commit is contained in:
caheckman 2022-10-05 11:26:29 -04:00
parent f7bb9e9e43
commit 35cfd02d87
4 changed files with 18 additions and 3 deletions

View file

@ -214,7 +214,6 @@ int main(int argc,char **argv)
if (initscript != (const char *)0) {
try {
status->setErrorIsDone(true);
status->pushScript(initscript,"init> ");
} catch(IfaceParseError &err) {
*status->optr << err.explain << endl;

View file

@ -4661,6 +4661,8 @@ void ActionInferTypes::propagateRef(Funcdata &data,Varnode *vn,const Address &ad
++iter;
if (curvn->isAnnotation()) continue;
if ((!curvn->isWritten())&&curvn->hasNoDescend()) continue;
if (curvn->isTypeLock()) continue;
if (curvn->getSymbolEntry() != (SymbolEntry *)0) continue;
uintb curoff = curvn->getOffset() - off;
int4 cursize = curvn->getSize();
if (curoff + cursize > ct->getSize()) continue;

View file

@ -162,6 +162,7 @@ void IfaceStatus::pushScript(istream *iptr,const string &newprompt)
if (errorisdone)
flags |= 1;
flagstack.push_back(flags);
errorisdone = true; // Abort on first exception in a script
prompt = newprompt;
}

View file

@ -48,8 +48,21 @@ bool RangeHint::reconcile(const RangeHint *b) const
if (sub == (Datatype *)0) return false;
if (umod != 0) return false;
if (sub->getSize() < b->type->getSize()) return false;
return true;
if (sub->getSize() == b->type->getSize()) return true;
if ((b->flags & Varnode::typelock)!=0) return false;
// If we reach here, component sizes do not match
// Check for data-types we want to protect more
type_metatype meta = a->type->getMetatype();
if (meta != TYPE_STRUCT && meta != TYPE_UNION) {
if (meta != TYPE_ARRAY || ((TypeArray *)(a->type))->getBase()->getMetatype() == TYPE_UNKNOWN)
return false;
}
// For structures, unions, and arrays, test if b looks like a partial data-type
meta = b->type->getMetatype();
if (meta == TYPE_UNKNOWN || meta == TYPE_INT || meta == TYPE_UINT) {
return true;
}
return false;
}
/// \brief Return \b true if \b this or the given range contains the other.