1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 03:28:20 +02:00

PDB parsing hardening

This commit is contained in:
Brian Fiete 2022-08-26 14:02:37 -07:00
parent 311cdaece1
commit 6eddf12948
2 changed files with 14 additions and 8 deletions

View file

@ -512,7 +512,6 @@ DbgType* COFF::CvGetType(int typeId)
{
TYPE_ENUM_e typeEnum = (TYPE_ENUM_e)typeId;
DbgType* type = mCvSystemTypes[typeId];
BF_ASSERT(type != NULL);
return type;
}
@ -3439,11 +3438,11 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c
if (moduleInfo != NULL)
{
BfLogDbgHI("ParseCompileUnit %s %s\n", mPDBPath.c_str(), moduleInfo->mModuleName);
BfLogDbg("ParseCompileUnit %s %s\n", mPDBPath.c_str(), moduleInfo->mModuleName);
}
else
{
BfLogDbgHI("ParseCompileUnit %s NULL\n", mPDBPath.c_str());
BfLogDbg("ParseCompileUnit %s NULL\n", mPDBPath.c_str());
}
int allocSizeStart = mAlloc.GetAllocSize();
@ -4127,6 +4126,8 @@ CvCompileUnit* COFF::ParseCompileUnit(int compileUnitId)
int sectionSize = 0;
uint8* sectionData = CvReadStream(moduleInfo->mStream, &sectionSize);
if (sectionData == NULL)
return NULL;
ParseCompileUnit(moduleInfo, NULL, sectionData, sectionSize);
delete sectionData;
return moduleInfo->mCompileUnit;
@ -4869,7 +4870,6 @@ uint8* COFF::CvReadStream(int streamIdx, int* outSize)
if ((streamIdx < 0) || (streamIdx >= mCvStreamSizes.mSize))
{
Fail(StrFormat("Invalid PDB stream index: %d", streamIdx));
return NULL;
}
@ -6257,10 +6257,13 @@ void COFF::ProcessDebugInfo()
{
compileUnit = ParseCompileUnit(NULL, compileUnit, entry.mData, entry.mSize);
}
compileUnit->mLanguage = DbgLanguage_Beef;
mMasterCompileUnit->mLanguage = DbgLanguage_Beef;
MapCompileUnitMethods(compileUnit);
mEndTypeIdx = (int)linkedModule->mTypes.size();
if (compileUnit != NULL)
{
compileUnit->mLanguage = DbgLanguage_Beef;
mMasterCompileUnit->mLanguage = DbgLanguage_Beef;
MapCompileUnitMethods(compileUnit);
mEndTypeIdx = (int)linkedModule->mTypes.size();
}
}
}

View file

@ -9638,6 +9638,9 @@ static void PdbTestFile(WinDebugger* debugger, const StringImpl& path)
for (int i = 0; i < coffFile.mTypes.mSize; i++)
coffFile.mTypes[i]->PopulateType();
for (int i = 0; i < coffFile.mCvModuleInfo.mSize; i++)
coffFile.ParseCompileUnit(i);
}
static void PdbTest(WinDebugger* debugger, const StringImpl& path)