diff options
Diffstat (limited to 'elf')
-rw-r--r-- | elf/dl-reloc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c index d2c6dac69e..97a7119d13 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -279,8 +279,12 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], l->l_name); } - l->l_reloc_result = calloc (sizeof (l->l_reloc_result[0]), - l->l_info[DT_PLTRELSZ]->d_un.d_val); + size_t sizeofrel = l->l_info[DT_PLTREL]->d_un.d_val == DT_RELA + ? sizeof (ElfW(Rela)) + : sizeof (ElfW(Rel)); + size_t relcount = l->l_info[DT_PLTRELSZ]->d_un.d_val / sizeofrel; + l->l_reloc_result = calloc (sizeof (l->l_reloc_result[0]), relcount); + if (l->l_reloc_result == NULL) { errstring = N_("\ |