X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Fmach-o.c;h=4e6408670dd7c1dfe2f2f59671934324bd79cd26;hb=a8eab7c6d529ddd248ff5243bb22e9346196e376;hp=122a0c26ccc1144d161d2c96063629c9245949b8;hpb=242a115951fe55e62036bac555017eb817ca1aa6;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/mach-o.c b/bfd/mach-o.c index 122a0c26cc..4e6408670d 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -647,7 +647,7 @@ cpusubtype (unsigned long cputype, unsigned long cpusubtype) break; } break; - + case BFD_MACH_O_CPU_TYPE_ARM: switch (cpusubtype) { @@ -667,7 +667,7 @@ cpusubtype (unsigned long cputype, unsigned long cpusubtype) break; } break; - + case BFD_MACH_O_CPU_TYPE_ARM64: switch (cpusubtype) { @@ -707,7 +707,7 @@ bfd_mach_o_bfd_print_private_bfd_data (bfd *abfd, void *ptr) fprintf (file, _(" sizeocmds: %#lx\n"), (long) mdata->header.sizeofcmds); fprintf (file, _(" flags: %#lx\n"), (long) mdata->header.flags); fprintf (file, _(" version: %x\n"), mdata->header.version); - + return TRUE; } @@ -748,7 +748,7 @@ bfd_mach_o_bfd_copy_private_header_data (bfd *ibfd, bfd *obfd) /* Copy the cpusubtype. */ omdata->header.cpusubtype = imdata->header.cpusubtype; - + /* Copy commands. */ for (icmd = imdata->first_command; icmd != NULL; icmd = icmd->next) { @@ -1501,7 +1501,11 @@ bfd_mach_o_canonicalize_non_scattered_reloc (bfd *abfd, { /* PR 17512: file: 006-2964-0.004. */ if (num > mdata->nsects) - return FALSE; + { + _bfd_error_handler (_("\ +malformed mach-o reloc: section index is greater than the number of sections")); + return FALSE; + } /* A section number. */ sym = mdata->sections[num - 1]->bfdsection->symbol_ptr_ptr; @@ -1609,7 +1613,7 @@ bfd_mach_o_canonicalize_relocs (bfd *abfd, unsigned long filepos, { bfd_mach_o_backend_data *bed = bfd_mach_o_get_backend_data (abfd); unsigned long i; - struct mach_o_reloc_info_external *native_relocs; + struct mach_o_reloc_info_external *native_relocs = NULL; bfd_size_type native_size; /* Allocate and read relocs. */ @@ -1617,7 +1621,7 @@ bfd_mach_o_canonicalize_relocs (bfd *abfd, unsigned long filepos, /* PR 17512: file: 09477b57. */ if (native_size < count) - return -1; + goto err; native_relocs = (struct mach_o_reloc_info_external *) bfd_malloc (native_size); @@ -1636,8 +1640,11 @@ bfd_mach_o_canonicalize_relocs (bfd *abfd, unsigned long filepos, } free (native_relocs); return i; + err: free (native_relocs); + if (bfd_get_error () == bfd_error_no_error) + bfd_set_error (bfd_error_invalid_operation); return -1; } @@ -4928,11 +4935,11 @@ bfd_mach_o_read_command (bfd *abfd, bfd_mach_o_load_command *command) break; case BFD_MACH_O_LC_NOTE: if (!bfd_mach_o_read_note (abfd, command)) - return FALSE; + return FALSE; break; case BFD_MACH_O_LC_BUILD_VERSION: if (!bfd_mach_o_read_build_version (abfd, command)) - return FALSE; + return FALSE; break; default: command->len = 0;