reloc_upper_bound size calculations
Section reloc_count is an unsigned int. Adding one for a NULL terminator to an array of arelent pointers can wrap the count to zero. Avoid that by doing the addition as longs. * coffgen.c (coff_get_reloc_upper_bound): Don't overflow unsigned int expression. * elf.c (_bfd_elf_get_reloc_upper_bound): Likewise. * elf64-sparc.c (elf64_sparc_get_reloc_upper_bound): Likewise. * mach-o.c (bfd_mach_o_get_reloc_upper_bound): Likewise. * vms-alpha.c (alpha_vms_get_reloc_upper_bound): Likewise.
This commit is contained in:
parent
472dd8b357
commit
5cfe19e51e
5 changed files with 5 additions and 5 deletions
|
@ -1996,7 +1996,7 @@ coff_get_reloc_upper_bound (bfd *abfd, sec_ptr asect)
|
|||
return -1;
|
||||
}
|
||||
#endif
|
||||
return (asect->reloc_count + 1) * sizeof (arelent *);
|
||||
return (asect->reloc_count + 1L) * sizeof (arelent *);
|
||||
}
|
||||
|
||||
asymbol *
|
||||
|
|
|
@ -8559,7 +8559,7 @@ _bfd_elf_get_reloc_upper_bound (bfd *abfd, sec_ptr asect)
|
|||
return -1;
|
||||
}
|
||||
#endif
|
||||
return (asect->reloc_count + 1) * sizeof (arelent *);
|
||||
return (asect->reloc_count + 1L) * sizeof (arelent *);
|
||||
}
|
||||
|
||||
/* Canonicalize the relocs. */
|
||||
|
|
|
@ -44,7 +44,7 @@ elf64_sparc_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
|
|||
return -1;
|
||||
}
|
||||
#endif
|
||||
return (sec->reloc_count * 2 + 1) * sizeof (arelent *);
|
||||
return (sec->reloc_count * 2L + 1) * sizeof (arelent *);
|
||||
}
|
||||
|
||||
static long
|
||||
|
|
|
@ -1427,7 +1427,7 @@ bfd_mach_o_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED,
|
|||
return -1;
|
||||
}
|
||||
#endif
|
||||
return (asect->reloc_count + 1) * sizeof (arelent *);
|
||||
return (asect->reloc_count + 1L) * sizeof (arelent *);
|
||||
}
|
||||
|
||||
/* In addition to the need to byte-swap the symbol number, the bit positions
|
||||
|
|
|
@ -5443,7 +5443,7 @@ alpha_vms_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED, asection *section)
|
|||
{
|
||||
alpha_vms_slurp_relocs (abfd);
|
||||
|
||||
return (section->reloc_count + 1) * sizeof (arelent *);
|
||||
return (section->reloc_count + 1L) * sizeof (arelent *);
|
||||
}
|
||||
|
||||
/* Convert relocations from VMS (external) form into BFD internal
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue