libdwfl: Make sure elf_getdata_rawchunk size_t doesn't overflow find_dynsym.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
This commit is contained in:
Mark Wielaard
2014-12-13 22:23:45 +01:00
parent f73385ef95
commit c8a0273dd5
2 changed files with 14 additions and 1 deletions
+5
View File
@@ -1,3 +1,8 @@
2014-12-13 Mark Wielaard <mjw@redhat.com>
* dwfl_module_getdwarf.c (find_dynsym): elf_getdata_rawchunk takes
a size_t, make sure it doesn't overflow.
2014-12-13 Mark Wielaard <mjw@redhat.com>
* cu.c (cudie_offset): Make sure Dwarf_Off difference doesn't
+9 -1
View File
@@ -768,7 +768,15 @@ find_dynsym (Dwfl_Module *mod)
* sizeof (Elf32_Word)
* header->maskwords));
data = elf_getdata_rawchunk (mod->main.elf, buckets_at,
// elf_getdata_rawchunk takes a size_t, make sure it
// doesn't overflow.
#if SIZE_MAX <= UINT32_MAX
if (nbuckets > SIZE_MAX / sizeof (Elf32_Word))
data = NULL;
else
#endif
data
= elf_getdata_rawchunk (mod->main.elf, buckets_at,
nbuckets * sizeof (Elf32_Word),
ELF_T_WORD);
if (data != NULL && symndx < nbuckets)