From: Tristan Gingold Date: Mon, 3 May 2010 10:23:33 +0000 (+0000) Subject: bfd/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ab94b07c4b703fe5d21d08294f43b4c1499db16f;p=binutils-gdb.git bfd/ 2010-05-03 Tristan Gingold * vms-lib.c (_bfd_vms_lib_archive_p): Adjust for a possible empty next array. (vms_lib_dcx): Adjust for the above change. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 74dd28b22ba..4caa817d9ae 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2010-05-03 Tristan Gingold + + * vms-lib.c (_bfd_vms_lib_archive_p): Adjust for a possible empty + next array. + (vms_lib_dcx): Adjust for the above change. + 2010-04-30 H.J. Lu PR ld/11542 diff --git a/bfd/vms-lib.c b/bfd/vms-lib.c index bd5ecb79a4c..bbef19c7f41 100644 --- a/bfd/vms-lib.c +++ b/bfd/vms-lib.c @@ -552,6 +552,7 @@ _bfd_vms_lib_archive_p (bfd *abfd, enum vms_lib_kind kind) struct dcxsbm_desc *sbmdesc = &tdata->dcxsbm[i]; unsigned int sbm_len; unsigned int sbm_sz; + unsigned int off; unsigned char *data = (unsigned char *)sbm; unsigned char *buf1; unsigned int l, j; @@ -565,16 +566,28 @@ _bfd_vms_lib_archive_p (bfd *abfd, enum vms_lib_kind kind) sbmdesc->max_char = sbm->max_char; sbm_len = sbmdesc->max_char - sbmdesc->min_char + 1; l = (2 * sbm_len + 7) / 8; - BFD_ASSERT (sbm_sz >= sizeof (struct vms_dcxsbm) + l + 3 * sbm_len); + BFD_ASSERT + (sbm_sz >= sizeof (struct vms_dcxsbm) + l + 3 * sbm_len + || (tdata->nbr_dcxsbm == 1 + && sbm_sz >= sizeof (struct vms_dcxsbm) + l + sbm_len)); sbmdesc->flags = (unsigned char *)bfd_alloc (abfd, l); memcpy (sbmdesc->flags, data + bfd_getl16 (sbm->flags), l); sbmdesc->nodes = (unsigned char *)bfd_alloc (abfd, 2 * sbm_len); memcpy (sbmdesc->nodes, data + bfd_getl16 (sbm->nodes), 2 * sbm_len); - sbmdesc->next = (unsigned short *)bfd_alloc - (abfd, sbm_len * sizeof (unsigned short)); - buf1 = data + bfd_getl16 (sbm->next); - for (j = 0; j < sbm_len; j++) - sbmdesc->next[j] = bfd_getl16 (buf1 + j * 2); + off = bfd_getl16 (sbm->next); + if (off != 0) + { + sbmdesc->next = (unsigned short *)bfd_alloc + (abfd, sbm_len * sizeof (unsigned short)); + buf1 = data + off; + for (j = 0; j < sbm_len; j++) + sbmdesc->next[j] = bfd_getl16 (buf1 + j * 2); + } + else + { + BFD_ASSERT (tdata->nbr_dcxsbm == 1); + sbmdesc->next = NULL; + } } free (buf); } @@ -850,7 +863,8 @@ vms_lib_dcx (struct vms_lib_iovec *vec, unsigned char *buf, file_ptr nbytes) { unsigned char v = sbm->nodes[offset]; - sbm = vec->dcxsbms + sbm->next[v]; + if (sbm->next != NULL) + sbm = vec->dcxsbms + sbm->next[v]; offset = 0; res++;