Skip to content

Commit 6e18613

Browse files
Mattiwattimrexodia
authored andcommitted
DBG: ReadExportDirectory: put upper bound on the number of imports
1 parent e38adf1 commit 6e18613

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/dbg/module.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ static void ReadExportDirectory(MODINFO & Info, ULONG_PTR FileMapVA)
8989
(ULONG_PTR)exportDir + exportDirSize < (ULONG_PTR)exportDir // Check for ULONG_PTR wraparound (e.g. when exportDirSize == 0xfffff000)
9090
|| exportDir->NumberOfFunctions == 0)
9191
return;
92+
DWORD64 totalFunctionSize = exportDir->NumberOfFunctions * sizeof(ULONG_PTR);
93+
if(totalFunctionSize / exportDir->NumberOfFunctions != sizeof(ULONG_PTR) || // Check for overflow
94+
totalFunctionSize > Info.loadedSize) // Check for impossible number of exports
95+
return;
9296

9397
auto rva2offset = [&Info](ULONG64 rva)
9498
{

0 commit comments

Comments
 (0)