File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1753,10 +1753,15 @@ bool PEView::Init()
17531753 }
17541754 }
17551755
1756- if (m_dataDirs[IMAGE_DIRECTORY_ENTRY_EXCEPTION ].size % entrySize)
1756+ const auto & exceptionDir = m_dataDirs[IMAGE_DIRECTORY_ENTRY_EXCEPTION ];
1757+ if (exceptionDir.size % entrySize)
17571758 throw PEFormatException (" invalid table size" );
1758- numExceptionEntries = m_dataDirs[IMAGE_DIRECTORY_ENTRY_EXCEPTION ].size / entrySize;
1759+ const auto imageSize = GetEnd () - GetStart ();
1760+ if ((exceptionDir.virtualAddress > imageSize)
1761+ || (exceptionDir.size > (imageSize - exceptionDir.virtualAddress )))
1762+ throw PEFormatException (" too many exception entries, table size exceeds available memory range" );
17591763
1764+ numExceptionEntries = exceptionDir.size / entrySize;
17601765 // This DataVariable can end up creating a large array and rendering this in LinearView currently has performance implications
17611766 // So instead we just create separate structures not in an array
17621767 Ref<Structure> exceptionEntryStruct = exceptionEntryBuilder.Finalize ();
You can’t perform that action at this time.
0 commit comments