Ghidra is a software reverse engineering (SRE) framework
GP-6995 SLEIGH decode checks
caheckman376ac1a0a04b
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.hhindex e3be244b3b..6fa3ed0bcd 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.hh@@ -92,7 +92,10 @@ public:SleighSymbol *findSymbol(const string &nm) const { return findSymbolInternal(curscope,nm); }SleighSymbol *findSymbol(const string &nm,int4 skip) const { return findSymbolInternal(skipScope(skip),nm); }SleighSymbol *findGlobalSymbol(const string &nm) const { return findSymbolInternal(table[0],nm); }- SleighSymbol *findSymbol(uintm id) const { return symbollist[id]; }+ SleighSymbol *findSymbol(uintm id) const {+ if (id >= symbollist.size())+ throw SleighError("Bad symbol id");+ return symbollist[id]; }void replaceSymbol(SleighSymbol *a,SleighSymbol *b);void encode(Encoder &encoder) const;void decode(Decoder &decoder,SleighBase *trans);diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/translate.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/translate.ccindex d5b5219b14..2bc5425031 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/translate.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/translate.cc@@ -269,8 +269,10 @@ AddrSpace *AddrSpaceManager::decodeSpace(Decoder &decoder,const Translate *transres.reset(new OtherSpace(this,trans));else if (elemId == ELEM_SPACE_OVERLAY)res.reset(new OverlaySpace(this,trans));- else+ else if (elemId == ELEM_SPACE)res.reset(new AddrSpace(this,trans,IPTR_PROCESSOR));+ else+ throw LowlevelError("Invalid address space element");res->decode(decoder);return res.release();