summaryrefslogtreecommitdiff
blob: 020f8b49dcd40b160c6b202805d3f5318d9ef64c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
--- 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);