This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PR 14567 bfd_openr_iovec vs archives

This PR is about trying to do anything with archive members when the
archive is opened with bfd_openr_iovec.  As the submitter correctly
said "_bfd_new_bfd_contained_in does not copy the iostream member from
the parent" resulting in NULL pointer dereferences since the
opncls_iovec functions expect iostream to point at a struct opncls.

	PR binutils/14567
	* opncls.c (opncls_iovec): Forward declare.
	(_bfd_new_bfd_contained_in): If using opncls_iovec, copy iostream
	to new bfd.

Index: bfd/opncls.c
RCS file: /cvs/src/src/bfd/opncls.c,v
retrieving revision 1.73
diff -u -p -r1.73 opncls.c
--- bfd/opncls.c	20 Aug 2012 14:32:31 -0000	1.73
+++ bfd/opncls.c	6 Nov 2012 01:52:14 -0000
@@ -107,6 +107,8 @@ _bfd_new_bfd (void)
   return nbfd;
+static const struct bfd_iovec opncls_iovec;
 /* Allocate a new BFD as a member of archive OBFD.  */
 bfd *
@@ -119,6 +121,8 @@ _bfd_new_bfd_contained_in (bfd *obfd)
     return NULL;
   nbfd->xvec = obfd->xvec;
   nbfd->iovec = obfd->iovec;
+  if (obfd->iovec == &opncls_iovec)
+    nbfd->iostream = obfd->iostream;
   nbfd->my_archive = obfd;
   nbfd->direction = read_direction;
   nbfd->target_defaulted = obfd->target_defaulted;

Alan Modra
Australia Development Lab, IBM

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]