gdb/gdb-6.3-gentoo_bfd_malloc_wrap.patch

24 lines
782 B
Diff
Raw Normal View History

--- bfd/elfcode.h.orig 2005-05-04 19:34:52.000000000 -0400
+++ bfd/elfcode.h 2005-05-04 19:37:35.000000000 -0400
@@ -640,6 +640,9 @@
Elf_Internal_Shdr *shdrp;
unsigned int num_sec;
+ if (sizeof(*i_shdrp)*i_ehdrp->e_shnum/sizeof(*i_shdrp)!=i_ehdrp->e_shnum)
+ goto got_no_match;
+
amt = sizeof (*i_shdrp) * i_ehdrp->e_shnum;
i_shdrp = bfd_alloc (abfd, amt);
if (!i_shdrp)
@@ -647,6 +650,10 @@
num_sec = i_ehdrp->e_shnum;
if (num_sec > SHN_LORESERVE)
num_sec += SHN_HIRESERVE + 1 - SHN_LORESERVE;
+
+ if (sizeof (i_shdrp) * num_sec/sizeof (i_shdrp) != num_sec)
+ goto got_no_match;
+
elf_numsections (abfd) = num_sec;
amt = sizeof (i_shdrp) * num_sec;
elf_elfsections (abfd) = bfd_alloc (abfd, amt);