[Lldb-commits] [lldb] r211102 - Avoid crashing on invalid or unreadable ELF core

Ed Maste emaste at freebsd.org
Tue Jun 17 07:14:33 PDT 2014


Author: emaste
Date: Tue Jun 17 09:14:33 2014
New Revision: 211102

URL: http://llvm.org/viewvc/llvm-project?rev=211102&view=rev
Log:
Avoid crashing on invalid or unreadable ELF core

Issue discovered during the GSoC 2014 project implementing FreeBSD
kernel support.  The existing elf-core Process plugin crashed trying
to read from /dev/mem (the kernel memory device).

Patch by Mike Ma.

Modified:
    lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp

Modified: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp?rev=211102&r1=211101&r2=211102&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp Tue Jun 17 09:14:33 2014
@@ -63,7 +63,8 @@ ProcessElfCore::CreateInstance (Target &
         const size_t header_size = sizeof(llvm::ELF::Elf64_Ehdr);
 
         lldb::DataBufferSP data_sp (crash_file->ReadFileContents(0, header_size));
-        if (data_sp->GetByteSize() == header_size && elf::ELFHeader::MagicBytesMatch (data_sp->GetBytes()))
+        if (data_sp && data_sp->GetByteSize() == header_size &&
+            elf::ELFHeader::MagicBytesMatch (data_sp->GetBytes()))
         {
             elf::ELFHeader elf_header;
             DataExtractor data(data_sp, lldb::eByteOrderLittle, 4);





More information about the lldb-commits mailing list