X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Fvms-alpha.c;h=b00ab2a54df11305c068dcb950dfcf5e3f1b1424;hb=99914dfd71d74bc700bb6d15647895ac0c8cc8e1;hp=8c24ef0c28171c25283ac5bb890aad0be93a0ebb;hpb=60bb06bc89858ee50ad02907a833565dcc317182;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index 8c24ef0c28..b00ab2a54d 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -1,5 +1,5 @@ /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files. - Copyright (C) 1996-2014 Free Software Foundation, Inc. + Copyright (C) 1996-2016 Free Software Foundation, Inc. Initial version written by Klaus Kaempf (kkaempf@rmi.de) Major rewrite by Adacore. @@ -521,9 +521,11 @@ _bfd_vms_slurp_eisd (bfd *abfd, unsigned int offset) asection *section; flagword bfd_flags; + /* PR 17512: file: 3d9e9fe9. */ + if (offset >= PRIV (recrd.rec_size)) + return FALSE; eisd = (struct vms_eisd *)(PRIV (recrd.rec) + offset); rec_size = bfd_getl32 (eisd->eisdsize); - if (rec_size == 0) break; @@ -827,7 +829,7 @@ vms_get_remaining_object_record (bfd *abfd, unsigned int read_so_far) /* PR 17512: file: 025-1974-0.004. */ else if (to_read <= read_so_far) return 0; - + /* Read the remaining record. */ to_read -= read_so_far; @@ -857,9 +859,12 @@ _bfd_vms_slurp_ehdr (bfd *abfd) { unsigned char *ptr; unsigned char *vms_rec; + unsigned char *end; int subtype; vms_rec = PRIV (recrd.rec); + /* PR 17512: file: 62736583. */ + end = PRIV (recrd.buf) + PRIV (recrd.buf_size); vms_debug2 ((2, "HDR/EMH\n")); @@ -871,28 +876,42 @@ _bfd_vms_slurp_ehdr (bfd *abfd) { case EMH__C_MHD: /* Module header. */ + if (vms_rec + 21 >= end) + goto fail; PRIV (hdr_data).hdr_b_strlvl = vms_rec[6]; PRIV (hdr_data).hdr_l_arch1 = bfd_getl32 (vms_rec + 8); PRIV (hdr_data).hdr_l_arch2 = bfd_getl32 (vms_rec + 12); PRIV (hdr_data).hdr_l_recsiz = bfd_getl32 (vms_rec + 16); + if ((vms_rec + 20 + vms_rec[20] + 1) >= end) + goto fail; PRIV (hdr_data).hdr_t_name = _bfd_vms_save_counted_string (vms_rec + 20); ptr = vms_rec + 20 + vms_rec[20] + 1; + if ((ptr + *ptr + 1) >= end) + goto fail; PRIV (hdr_data).hdr_t_version =_bfd_vms_save_counted_string (ptr); ptr += *ptr + 1; + if (ptr + 17 >= end) + goto fail; PRIV (hdr_data).hdr_t_date = _bfd_vms_save_sized_string (ptr, 17); break; case EMH__C_LNM: + if (vms_rec + PRIV (recrd.rec_size - 6) > end) + goto fail; PRIV (hdr_data).hdr_c_lnm = _bfd_vms_save_sized_string (vms_rec, PRIV (recrd.rec_size - 6)); break; case EMH__C_SRC: + if (vms_rec + PRIV (recrd.rec_size - 6) > end) + goto fail; PRIV (hdr_data).hdr_c_src = _bfd_vms_save_sized_string (vms_rec, PRIV (recrd.rec_size - 6)); break; case EMH__C_TTL: + if (vms_rec + PRIV (recrd.rec_size - 6) > end) + goto fail; PRIV (hdr_data).hdr_c_ttl = _bfd_vms_save_sized_string (vms_rec, PRIV (recrd.rec_size - 6)); break; @@ -903,6 +922,7 @@ _bfd_vms_slurp_ehdr (bfd *abfd) break; default: + fail: bfd_set_error (bfd_error_wrong_format); return FALSE; } @@ -1621,9 +1641,8 @@ _bfd_vms_get_value (bfd *abfd, const unsigned char *ascic, *vma = 0; else { - if (!(*info->callbacks->undefined_symbol) - (info, name, abfd, PRIV (image_section), PRIV (image_offset), TRUE)) - abort (); + (*info->callbacks->undefined_symbol) + (info, name, abfd, PRIV (image_section), PRIV (image_offset), TRUE); *vma = 0; } } @@ -2527,6 +2546,9 @@ alpha_vms_object_p (bfd *abfd) /* Reset the record pointer. */ PRIV (recrd.rec) = buf; + /* PR 17512: file: 7d7c57c2. */ + if (PRIV (recrd.rec_size) < sizeof (struct vms_eihd)) + goto error_ret; vms_debug2 ((2, "file type is image\n")); if (_bfd_vms_slurp_eihd (abfd, &eisd_offset, &eihs_offset) != TRUE) @@ -8179,7 +8201,7 @@ alpha_vms_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info) to include it. We don't need to check anything. */ if (!(*info->callbacks ->add_archive_element) (info, element, h->root.string, &element)) - return FALSE; + continue; if (!alpha_vms_link_add_object_symbols (element, info)) return FALSE; @@ -8574,7 +8596,7 @@ alpha_vms_bfd_final_link (bfd *abfd, struct bfd_link_info *info) asection *dst; asection *dmt; - if (info->relocatable) + if (bfd_link_relocatable (info)) { /* FIXME: we do not yet support relocatable link. It is not obvious how to do it for debug infos. */ @@ -8990,13 +9012,13 @@ vms_new_section_hook (bfd * abfd, asection *section) { bfd_size_type amt; - vms_debug2 ((1, "vms_new_section_hook (%p, [%d]%s)\n", + vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n", abfd, section->index, section->name)); if (! bfd_set_section_alignment (abfd, section, 0)) return FALSE; - vms_debug2 ((7, "%d: %s\n", section->index, section->name)); + vms_debug2 ((7, "%u: %s\n", section->index, section->name)); amt = sizeof (struct vms_section_data_struct); section->used_by_bfd = bfd_zalloc (abfd, amt); @@ -9237,6 +9259,7 @@ bfd_vms_get_data (bfd *abfd) _bfd_nodynamic_get_dynamic_reloc_upper_bound #define alpha_vms_canonicalize_dynamic_reloc \ _bfd_nodynamic_canonicalize_dynamic_reloc +#define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs const bfd_target alpha_vms_vec = {