This is the mail archive of the binutils@sourceware.org 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]

Re: PATCH: PR binutils/12632: strip crashes when it does not recognise the file format


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;
 }


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