1
0
Fork 0

DBG: ReadExportDirectory: put upper bound on the number of imports

This commit is contained in:
Mattiwatti 2019-03-14 00:39:31 +01:00 committed by Duncan Ogilvie
parent e38adf1265
commit 6e18613e37
1 changed files with 4 additions and 0 deletions

View File

@ -89,6 +89,10 @@ static void ReadExportDirectory(MODINFO & Info, ULONG_PTR FileMapVA)
(ULONG_PTR)exportDir + exportDirSize < (ULONG_PTR)exportDir // Check for ULONG_PTR wraparound (e.g. when exportDirSize == 0xfffff000)
|| exportDir->NumberOfFunctions == 0)
return;
DWORD64 totalFunctionSize = exportDir->NumberOfFunctions * sizeof(ULONG_PTR);
if(totalFunctionSize / exportDir->NumberOfFunctions != sizeof(ULONG_PTR) || // Check for overflow
totalFunctionSize > Info.loadedSize) // Check for impossible number of exports
return;
auto rva2offset = [&Info](ULONG64 rva)
{