summaryrefslogtreecommitdiff
path: root/view/elf
diff options
context:
space:
mode:
authorJosh Ferrell <josh@vector35.com>2026-01-22 19:42:44 -0500
committerJosh Ferrell <josh@vector35.com>2026-01-22 19:42:54 -0500
commit4e72219707ba28e7ca18816cb74c664006696d99 (patch)
tree5d4ed9b8ed5c8a519fba5cdaf6220e35ddcd1ed7 /view/elf
parent14a8c76b46354826d79431168749ed81963db034 (diff)
[ELF] Fix reading dynamic string tables at large offsets
Diffstat (limited to 'view/elf')
-rw-r--r--view/elf/elfview.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/view/elf/elfview.cpp b/view/elf/elfview.cpp
index 8d0fde46..3a4b37fe 100644
--- a/view/elf/elfview.cpp
+++ b/view/elf/elfview.cpp
@@ -2680,16 +2680,16 @@ string ElfView::ReadStringTable(BinaryReader& reader, const Elf64SectionHeader&
auto itr = m_stringTableCache.find(section.offset);
if (itr == m_stringTableCache.end())
{
- if (section.size > GetParentView()->GetLength())
+ reader.Seek(section.offset);
+ std::vector<char> dest;
+ dest.resize(section.size);
+ // We could be using a virtual reader so we can't rely on comparison against the parent view length - we just need to try and read
+ if (!reader.TryRead(dest.data(), section.size))
{
m_logger->LogError("Unable to read string table with section offset: 0x%" PRIx64 " size: 0x%" PRIx64, section.offset, section.size);
return "";
}
-
- std::vector<char>& tableCache = m_stringTableCache[section.offset];
- tableCache.resize(section.size);
- reader.Seek(section.offset);
- reader.Read(tableCache.data(), section.size);
+ m_stringTableCache[section.offset] = std::move(dest);
itr = m_stringTableCache.find(section.offset);
}