Skip to content

Commit fc21d13

Browse files
committed
Fix out of bounds access when increasing program header table
1 parent 683e41d commit fc21d13

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
@@ -689,7 +689,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
689689
/* Some sections may already be replaced so account for that */
690690
unsigned int i = 1;
691691
Elf_Addr pht_size = sizeof(Elf_Ehdr) + (phdrs.size() + num_notes + 1)*sizeof(Elf_Phdr);
692-
while( rdi(shdrs.at(i).sh_offset) <= pht_size && i < rdi(hdr()->e_shnum) ) {
692+
while( i < rdi(hdr()->e_shnum) && rdi(shdrs.at(i).sh_offset) <= pht_size ) {
693693
if (not haveReplacedSection(getSectionName(shdrs.at(i))))
694694
replaceSection(getSectionName(shdrs.at(i)), rdi(shdrs.at(i).sh_size));
695695
i++;

0 commit comments

Comments
 (0)