mirror of
https://github.com/NixOS/patchelf.git
synced 2025-10-24 03:12:49 +08:00
Fix endian issue when creating sectionsByOldIndex
sectionsByOldIndex was resized to hdr->e_shnum instead of rdi(hdr->e_shnum). This omitted the endianness conversion and probably only worked by accident, because the 16-bit LE->BE conversion results in integers that are larger as long as there no more than 255 section headers. This would be a good usecase for std::transform, but I'm unsure whether we want to bump requirements to build patchelf to C++ 2017.
This commit is contained in:
@@ -447,8 +447,8 @@ ElfFile<ElfFileParamNames>::ElfFile(FileContents fileContents)
|
||||
|
||||
sectionNames = std::string(shstrtab, shstrtabSize);
|
||||
|
||||
sectionsByOldIndex.resize(hdr->e_shnum);
|
||||
for (unsigned int i = 1; i < rdi(hdr->e_shnum); ++i)
|
||||
sectionsByOldIndex.resize(shdrs.size());
|
||||
for (size_t i = 1; i < shdrs.size(); ++i)
|
||||
sectionsByOldIndex[i] = getSectionName(shdrs[i]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user