summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp')
-rw-r--r--lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 119616d0c5e..d24508f6672 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -1148,9 +1148,25 @@ DynamicLoaderDarwinKernel::ReadKextSummaryHeader ()
{
lldb::offset_t offset = 0;
m_kext_summary_header.version = data.GetU32(&offset);
+ if (m_kext_summary_header.version > 128)
+ {
+ Stream *s = m_process->GetTarget().GetDebugger().GetOutputFile().get();
+ s->Printf ("WARNING: Unable to read kext summary header, got improbable version number %u\n", m_kext_summary_header.version);
+ // If we get an improbably large veriosn number, we're probably getting bad memory.
+ m_kext_summary_header_addr.Clear();
+ return false;
+ }
if (m_kext_summary_header.version >= 2)
{
m_kext_summary_header.entry_size = data.GetU32(&offset);
+ if (m_kext_summary_header.entry_size > 4096)
+ {
+ // If we get an improbably large entry_size, we're probably getting bad memory.
+ Stream *s = m_process->GetTarget().GetDebugger().GetOutputFile().get();
+ s->Printf ("WARNING: Unable to read kext summary header, got improbable entry_size %u\n", m_kext_summary_header.entry_size);
+ m_kext_summary_header_addr.Clear();
+ return false;
+ }
}
else
{
@@ -1158,6 +1174,14 @@ DynamicLoaderDarwinKernel::ReadKextSummaryHeader ()
m_kext_summary_header.entry_size = KERNEL_MODULE_ENTRY_SIZE_VERSION_1;
}
m_kext_summary_header.entry_count = data.GetU32(&offset);
+ if (m_kext_summary_header.entry_count > 10000)
+ {
+ // If we get an improbably large number of kexts, we're probably getting bad memory.
+ Stream *s = m_process->GetTarget().GetDebugger().GetOutputFile().get();
+ s->Printf ("WARNING: Unable to read kext summary header, got improbable number of kexts %u\n", m_kext_summary_header.entry_count);
+ m_kext_summary_header_addr.Clear();
+ return false;
+ }
return true;
}
}
OpenPOWER on IntegriCloud