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
This commit is contained in:
@@ -200,7 +200,8 @@ ImageFile::ImageFile(const image_info& info)
|
|||||||
fLoadDelta(0),
|
fLoadDelta(0),
|
||||||
fSymbolTable(NULL),
|
fSymbolTable(NULL),
|
||||||
fStringTable(NULL),
|
fStringTable(NULL),
|
||||||
fSymbolCount(0)
|
fSymbolCount(0),
|
||||||
|
fStringTableSize(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,6 +301,7 @@ ImageFile::Load()
|
|||||||
= (const Elf32_Sym*)(fMappedFile + sectionHeader->sh_offset);
|
= (const Elf32_Sym*)(fMappedFile + sectionHeader->sh_offset);
|
||||||
fStringTable = (const char*)(fMappedFile + stringHeader.sh_offset);
|
fStringTable = (const char*)(fMappedFile + stringHeader.sh_offset);
|
||||||
fSymbolCount = sectionHeader->sh_size / sizeof(Elf32_Sym);
|
fSymbolCount = sectionHeader->sh_size / sizeof(Elf32_Sym);
|
||||||
|
fStringTableSize = stringHeader.sh_size;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -392,12 +394,12 @@ size_t
|
|||||||
ImageFile::_SymbolNameLen(const char* symbolName) const
|
ImageFile::_SymbolNameLen(const char* symbolName) const
|
||||||
{
|
{
|
||||||
if (symbolName == NULL || (addr_t)symbolName < (addr_t)fStringTable
|
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 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return strnlen(symbolName,
|
return strnlen(symbolName,
|
||||||
(addr_t)fMappedFile + fFileSize - (addr_t)symbolName);
|
(addr_t)fStringTable + fStringTableSize - (addr_t)symbolName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ private:
|
|||||||
const Elf32_Sym* fSymbolTable;
|
const Elf32_Sym* fSymbolTable;
|
||||||
const char* fStringTable;
|
const char* fStringTable;
|
||||||
int32 fSymbolCount;
|
int32 fSymbolCount;
|
||||||
|
size_t fStringTableSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user