This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: PR binutils/12632: strip crashes when it does not recognise the file format
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Sun, 3 Apr 2011 14:46:12 -0700
- Subject: Re: PATCH: PR binutils/12632: strip crashes when it does not recognise the file format
- References: <20110403214252.GA15323@intel.com>
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
On Sun, Apr 03, 2011 at 02:42:52PM -0700, H.J. Lu wrote:
> Hi,
>
> When we copy an unknown archive element, we chmod to the mode in
> archive. If its mode happens to be unreadable by user, fopen returns
> NULL since we don't have permission to read it. This patch makes sure
> that the temp file written by strip is readable by strip. OK for
> trunk?
>
> Thanks.
>
>
> H.J.
> ---
> 2011-04-03 H.J. Lu <hongjiu.lu@intel.com>
>
> PR binutils/12632
> * objcopy.c (copy_unknown_object): Make the archive element
> readable.
>
A simpler patch.
H.J.
---
2011-04-03 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/12632
* objcopy.c (copy_unknown_object): Make the archive element
readable.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 77eaa34..15c4f95 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1399,7 +1399,9 @@ copy_unknown_object (bfd *ibfd, bfd *obfd)
ncopied += tocopy;
}
- chmod (bfd_get_filename (obfd), buf.st_mode);
+ /* We should at least to be able to read it back when copying an
+ unknown object in an archive. */
+ chmod (bfd_get_filename (obfd), buf.st_mode | S_IRUSR);
free (cbuf);
return TRUE;
}