summaryrefslogtreecommitdiff
path: root/view/pe/peview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'view/pe/peview.cpp')
-rw-r--r--view/pe/peview.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/view/pe/peview.cpp b/view/pe/peview.cpp
index 718822ba..a793eeb3 100644
--- a/view/pe/peview.cpp
+++ b/view/pe/peview.cpp
@@ -1753,10 +1753,15 @@ bool PEView::Init()
}
}
- if (m_dataDirs[IMAGE_DIRECTORY_ENTRY_EXCEPTION].size % entrySize)
+ const auto& exceptionDir = m_dataDirs[IMAGE_DIRECTORY_ENTRY_EXCEPTION];
+ if (exceptionDir.size % entrySize)
throw PEFormatException("invalid table size");
- numExceptionEntries = m_dataDirs[IMAGE_DIRECTORY_ENTRY_EXCEPTION].size / entrySize;
+ const auto imageSize = GetEnd() - GetStart();
+ if ((exceptionDir.virtualAddress > imageSize)
+ || (exceptionDir.size > (imageSize - exceptionDir.virtualAddress)))
+ throw PEFormatException("too many exception entries, table size exceeds available memory range");
+ numExceptionEntries = exceptionDir.size / entrySize;
// This DataVariable can end up creating a large array and rendering this in LinearView currently has performance implications
// So instead we just create separate structures not in an array
Ref<Structure> exceptionEntryStruct = exceptionEntryBuilder.Finalize();