Skip to content

Commit 742e319

Browse files
phix33trufae
authored andcommitted
Fix heap out of bounds read in the ppc64 plt stub segment scan ##bin
1 parent 6b32cbb commit 742e319

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

libr/bin/format/elf/plt.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,9 @@ void Elf_(plt_ppc64v1_load_text_stubs)(ELFOBJ *eo) {
645645
}
646646
}
647647
if (!scanned && eo->phdr) {
648-
int i;
649-
for (i = 0; i < eo->ehdr.e_phnum; i++) {
648+
size_t i;
649+
// phnum is the resolved count, e_phnum is 0xffff under PN_XNUM
650+
for (i = 0; i < eo->phnum; i++) {
650651
const Elf_(Phdr) *p = &eo->phdr[i];
651652
if (p->p_type == PT_LOAD && (p->p_flags & PF_X)) {
652653
ppc64v1_scan_stubs (eo, &sc, p->p_offset, p->p_vaddr, p->p_filesz);

0 commit comments

Comments
 (0)