This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
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:42:52 -0700
- Subject: PATCH: PR binutils/12632: strip crashes when it does not recognise the file format
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
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.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 77eaa34..489e060 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1399,6 +1399,10 @@ copy_unknown_object (bfd *ibfd, bfd *obfd)
ncopied += tocopy;
}
+ /* We should at least to be able to read it back when copying an
+ unknown object in an archive. */
+ if ((buf.st_mode & S_IRUSR) == 0)
+ buf.st_mode |= S_IRUSR;
chmod (bfd_get_filename (obfd), buf.st_mode);
free (cbuf);
return TRUE;