Skip to content

Commit 55d5db9

Browse files
authored
Merge pull request #411 from Bo98/notes-bounds
Fix out of bounds access when increasing program header table
2 parents 8032973 + fc21d13 commit 55d5db9

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
@@ -701,7 +701,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
701701
/* Some sections may already be replaced so account for that */
702702
unsigned int i = 1;
703703
Elf_Addr pht_size = sizeof(Elf_Ehdr) + (phdrs.size() + num_notes + 1)*sizeof(Elf_Phdr);
704-
while( rdi(shdrs.at(i).sh_offset) <= pht_size && i < rdi(hdr()->e_shnum) ) {
704+
while( i < rdi(hdr()->e_shnum) && rdi(shdrs.at(i).sh_offset) <= pht_size ) {
705705
if (not haveReplacedSection(getSectionName(shdrs.at(i))))
706706
replaceSection(getSectionName(shdrs.at(i)), rdi(shdrs.at(i).sh_size));
707707
i++;

0 commit comments

Comments
 (0)