From 7ada326834bed8264812b4ff99ce5ac2ec7f5567 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 21 Sep 2008 23:38:46 +0000 Subject: [PATCH] Also store the string table size for an image. This helps to improve the symbol name len check. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27682 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/debug/SymbolLookup.cpp | 8 +++++--- src/kits/debug/SymbolLookup.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/kits/debug/SymbolLookup.cpp b/src/kits/debug/SymbolLookup.cpp index fd043e5e0c..440370dd84 100644 --- a/src/kits/debug/SymbolLookup.cpp +++ b/src/kits/debug/SymbolLookup.cpp @@ -200,7 +200,8 @@ ImageFile::ImageFile(const image_info& info) fLoadDelta(0), fSymbolTable(NULL), fStringTable(NULL), - fSymbolCount(0) + fSymbolCount(0), + fStringTableSize(0) { } @@ -300,6 +301,7 @@ ImageFile::Load() = (const Elf32_Sym*)(fMappedFile + sectionHeader->sh_offset); fStringTable = (const char*)(fMappedFile + stringHeader.sh_offset); fSymbolCount = sectionHeader->sh_size / sizeof(Elf32_Sym); + fStringTableSize = stringHeader.sh_size; return B_OK; } @@ -392,12 +394,12 @@ size_t ImageFile::_SymbolNameLen(const char* symbolName) const { if (symbolName == NULL || (addr_t)symbolName < (addr_t)fStringTable - || (addr_t)symbolName >= (addr_t)fMappedFile + fFileSize) { + || (addr_t)symbolName >= (addr_t)fStringTable + fStringTableSize) { return 0; } return strnlen(symbolName, - (addr_t)fMappedFile + fFileSize - (addr_t)symbolName); + (addr_t)fStringTable + fStringTableSize - (addr_t)symbolName); } diff --git a/src/kits/debug/SymbolLookup.h b/src/kits/debug/SymbolLookup.h index ebe1e07d54..589258ff72 100644 --- a/src/kits/debug/SymbolLookup.h +++ b/src/kits/debug/SymbolLookup.h @@ -152,6 +152,7 @@ private: const Elf32_Sym* fSymbolTable; const char* fStringTable; int32 fSymbolCount; + size_t fStringTableSize; };