aboutsummaryrefslogtreecommitdiff
path: root/bfd/mach-o.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/mach-o.c')
-rw-r--r--bfd/mach-o.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index c13fff3..31ffa84 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -1349,8 +1349,12 @@ bfd_mach_o_canonicalize_one_reloc (bfd *abfd,
if (reloc.r_extern)
{
- /* An external symbol number. */
- sym = syms + num;
+ /* PR 17512: file: 8396-1185-0.004. */
+ if (num >= bfd_get_symcount (abfd))
+ sym = bfd_und_section_ptr->symbol_ptr_ptr;
+ else
+ /* An external symbol number. */
+ sym = syms + num;
}
else if (num == 0x00ffffff || num == 0)
{
@@ -2336,17 +2340,20 @@ bfd_mach_o_mangle_sections (bfd *abfd, bfd_mach_o_data_struct *mdata)
&& (mdata->nsects == 0 || mdata->sections != NULL))
return TRUE;
+ /* We need to check that this can be done... */
+ if (nsect > 255)
+ {
+ (*_bfd_error_handler) (_("mach-o: there are too many sections (%u)"
+ " maximum is 255,\n"), nsect);
+ return FALSE;
+ }
+
mdata->nsects = nsect;
mdata->sections = bfd_alloc (abfd,
mdata->nsects * sizeof (bfd_mach_o_section *));
if (mdata->sections == NULL)
return FALSE;
- /* We need to check that this can be done... */
- if (nsect > 255)
- (*_bfd_error_handler) (_("mach-o: there are too many sections (%d)"
- " maximum is 255,\n"), nsect);
-
/* Create Mach-O sections.
Section type, attribute and align should have been set when the
section was created - either read in or specified. */
@@ -3646,6 +3653,9 @@ bfd_mach_o_read_symtab_strtab (bfd *abfd)
if (bfd_seek (abfd, sym->stroff, SEEK_SET) != 0
|| bfd_bread (sym->strtab, sym->strsize, abfd) != sym->strsize)
{
+ /* PR 17512: file: 10888-1609-0.004. */
+ bfd_release (abfd, sym->strtab);
+ sym->strtab = NULL;
bfd_set_error (bfd_error_file_truncated);
return FALSE;
}
@@ -3675,6 +3685,7 @@ bfd_mach_o_read_symtab_symbols (bfd *abfd)
if (!bfd_mach_o_read_symtab_strtab (abfd))
{
+ bfd_release (abfd, sym->symbols);
sym->symbols = NULL;
return FALSE;
}
@@ -3683,6 +3694,7 @@ bfd_mach_o_read_symtab_symbols (bfd *abfd)
{
if (!bfd_mach_o_read_symtab_symbol (abfd, sym, &sym->symbols[i], i))
{
+ bfd_release (abfd, sym->symbols);
sym->symbols = NULL;
return FALSE;
}