[Lldb-commits] [lldb] r143362 - /lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Greg Clayton
gclayton at apple.com
Mon Oct 31 13:50:40 PDT 2011
Author: gclayton
Date: Mon Oct 31 15:50:40 2011
New Revision: 143362
URL: http://llvm.org/viewvc/llvm-project?rev=143362&view=rev
Log:
<rdar://problem/10368163>
Fixed an issue where if a mach-o symbol table was corrupt and had a string
table offset that is invalid, we could crash. We now properly check the string
table offset and ignore any symbols with invalid strings.
Modified:
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=143362&r1=143361&r2=143362&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Mon Oct 31 15:50:40 2011
@@ -772,8 +772,7 @@
DataBufferSP strtab_data_sp(m_file.ReadFileContents(m_offset + symtab_load_command.stroff, symtab_load_command.strsize));
const char *strtab_data = (const char *)strtab_data_sp->GetBytes();
-// DataExtractor symtab_data(symtab_data_sp, endian, addr_size);
-// DataExtractor strtab_data(strtab_data_sp, endian, addr_size);
+ const size_t strtab_data_len = strtab_data_sp->GetByteSize();
static ConstString g_segment_name_TEXT ("__TEXT");
static ConstString g_segment_name_DATA ("__DATA");
@@ -840,7 +839,21 @@
}
SymbolType type = eSymbolTypeInvalid;
+ if (nlist.n_strx >= strtab_data_len)
+ {
+ // No symbol should be NULL, even the symbols with no
+ // string values should have an offset zero which points
+ // to an empty C-string
+ fprintf (stderr,
+ "error: symbol[%u] has invalid string table offset 0x%x in %s/%s, ignoring symbol\n",
+ nlist_idx,
+ nlist.n_strx,
+ m_module->GetFileSpec().GetDirectory().GetCString(),
+ m_module->GetFileSpec().GetFilename().GetCString());
+ continue;
+ }
const char* symbol_name = &strtab_data[nlist.n_strx];
+
if (symbol_name[0] == '\0')
symbol_name = NULL;
Section* symbol_section = NULL;
More information about the lldb-commits
mailing list