Skip to content

Commit eb1f61a

Browse files
Bo98Ericson2314
authored andcommitted
Fix out of bounds access when increasing program header table
(cherry picked from commit fc21d13)
1 parent 5b27dc4 commit eb1f61a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/patchelf.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
679679
/* Some sections may already be replaced so account for that */
680680
unsigned int i = 1;
681681
Elf_Addr pht_size = sizeof(Elf_Ehdr) + (phdrs.size() + num_notes + 1)*sizeof(Elf_Phdr);
682-
while( rdi(shdrs.at(i).sh_offset) <= pht_size && i < rdi(hdr()->e_shnum) ) {
682+
while( i < rdi(hdr()->e_shnum) && rdi(shdrs.at(i).sh_offset) <= pht_size ) {
683683
if (not haveReplacedSection(getSectionName(shdrs.at(i))))
684684
replaceSection(getSectionName(shdrs.at(i)), rdi(shdrs.at(i).sh_size));
685685
i++;

0 commit comments

Comments
 (0)