Skip to content

Commit bcc4047

Browse files
committed
validation for zero sized symbol or string tables
1 parent 1530770 commit bcc4047

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

view/elf/elfview.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,10 +1094,14 @@ bool ElfView::Init()
10941094
DefineAutoSymbol(new Symbol(DataSymbol, "__elf_hash_table", m_hashHeader, NoBinding));
10951095

10961096
// Gratuitously create sections for the symbol and string tables if none exist
1097-
if (!GetSectionsAt(m_auxSymbolTable.offset).size())
1097+
if (m_auxSymbolTable.size && !GetSectionsAt(m_auxSymbolTable.offset).size())
10981098
AddAutoSection(".dynamic_symtab", m_auxSymbolTable.offset, m_auxSymbolTable.size, ReadOnlyDataSectionSemantics);
1099-
if (!GetSectionsAt(m_dynamicStringTable.offset).size())
1099+
else if (!m_auxSymbolTable.size)
1100+
m_logger->LogWarn("Skipping zero-length .dynamic_symtab section at 0x%" PRIx64, m_auxSymbolTable.offset);
1101+
if (m_dynamicStringTable.size && !GetSectionsAt(m_dynamicStringTable.offset).size())
11001102
AddAutoSection(".dynamic_strtab", m_dynamicStringTable.offset, m_dynamicStringTable.size, ReadOnlyDataSectionSemantics);
1103+
else if (!m_dynamicStringTable.size)
1104+
m_logger->LogWarn("Skipping zero-length .dynamic_strtab section at 0x%" PRIx64, m_dynamicStringTable.offset);
11011105
}
11021106

11031107
// Parse and create types for ELF GNU hash table

0 commit comments

Comments
 (0)