mirror of
https://github.com/NixOS/patchelf.git
synced 2025-10-18 17:42:36 +08:00
Fix out of bounds access when increasing program header table
This commit is contained in:
@@ -689,7 +689,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
|
|||||||
/* Some sections may already be replaced so account for that */
|
/* Some sections may already be replaced so account for that */
|
||||||
unsigned int i = 1;
|
unsigned int i = 1;
|
||||||
Elf_Addr pht_size = sizeof(Elf_Ehdr) + (phdrs.size() + num_notes + 1)*sizeof(Elf_Phdr);
|
Elf_Addr pht_size = sizeof(Elf_Ehdr) + (phdrs.size() + num_notes + 1)*sizeof(Elf_Phdr);
|
||||||
while( rdi(shdrs.at(i).sh_offset) <= pht_size && i < rdi(hdr()->e_shnum) ) {
|
while( i < rdi(hdr()->e_shnum) && rdi(shdrs.at(i).sh_offset) <= pht_size ) {
|
||||||
if (not haveReplacedSection(getSectionName(shdrs.at(i))))
|
if (not haveReplacedSection(getSectionName(shdrs.at(i))))
|
||||||
replaceSection(getSectionName(shdrs.at(i)), rdi(shdrs.at(i).sh_size));
|
replaceSection(getSectionName(shdrs.at(i)), rdi(shdrs.at(i).sh_size));
|
||||||
i++;
|
i++;
|
||||||
|
Reference in New Issue
Block a user