Skip to content

Commit af6b2cc

Browse files
committed
[PE] Add a fast fail for malformed PE exception directory table size
Fixes Vector35/binaryninja#1472
1 parent 9f6284b commit af6b2cc

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

view/pe/peview.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,8 @@ bool PEView::Init()
17561756
if (m_dataDirs[IMAGE_DIRECTORY_ENTRY_EXCEPTION].size % entrySize)
17571757
throw PEFormatException("invalid table size");
17581758
numExceptionEntries = m_dataDirs[IMAGE_DIRECTORY_ENTRY_EXCEPTION].size / entrySize;
1759+
if (numExceptionEntries > (GetEnd() - GetStart()) / entrySize)
1760+
throw PEFormatException("too many exception entries, table size exceeds available memory range");
17591761

17601762
// This DataVariable can end up creating a large array and rendering this in LinearView currently has performance implications
17611763
// So instead we just create separate structures not in an array

0 commit comments

Comments
 (0)