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

H.J. Lu hongjiu.lu@intel.com
Sun Apr 3 21:42:00 GMT 2011


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;



More information about the Binutils mailing list