]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix objcopy and strip so that they remove their temporary files even if an error... users/ibm/binutils-2_24
authorNick Clifton <nickc@redhat.com>
Mon, 10 Nov 2014 14:28:43 +0000 (14:28 +0000)
committerTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Tue, 10 Mar 2015 12:17:34 +0000 (09:17 -0300)
PR binutils/17552
* (copy_archive): Clean up temporary files even if an error
occurs.

binutils/ChangeLog
binutils/objcopy.c

index 53789b5a4a1e351afdd4b6e05d1246f0fdf9db3d..7e4cdec8c163700d7a0d7616b4197eca32acd616 100644 (file)
@@ -1,3 +1,9 @@
+2014-11-10  Nick Clifton  <nickc@redhat.com>
+
+       PR binutils/17552
+       * (copy_archive): Clean up temporary files even if an error
+       occurs.
+
 2014-11-06  Nick Clifton  <nickc@redhat.com>
 
        PR binutils/17552, binutils/17533
index 495e5c2405045f37bbdb05e72ec4f7012777c8ec..bd46a0a2296c989ca35a1eb1a29950088588b10a 100644 (file)
@@ -2209,8 +2209,12 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
       /* PR binutils/17533: Do not allow directory traversal
         outside of the current directory tree by archive members.  */
       if (! is_valid_archive_path (bfd_get_filename (this_element)))
-       fatal (_("illegal pathname found in archive member: %s"),
-              bfd_get_filename (this_element));
+       {
+         non_fatal (_("illegal pathname found in archive member: %s"),
+                    bfd_get_filename (this_element));
+         status = 1;
+         goto cleanup_and_exit;
+       }
 
       /* Create an output file for this member.  */
       output_name = concat (dir, "/",
@@ -2221,8 +2225,12 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
        {
          output_name = make_tempdir (output_name);
          if (output_name == NULL)
-           fatal (_("cannot create tempdir for archive copying (error: %s)"),
-                  strerror (errno));
+           {
+             non_fatal (_("cannot create tempdir for archive copying (error: %s)"),
+                        strerror (errno));
+             status = 1;
+             goto cleanup_and_exit;
+           }
 
          l = (struct name_list *) xmalloc (sizeof (struct name_list));
          l->name = output_name;
@@ -2264,7 +2272,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
        {
          bfd_nonfatal_message (output_name, NULL, NULL, NULL);
          status = 1;
-         return;
+         goto cleanup_and_exit;
        }
 
       if (ok_object)
@@ -2325,7 +2333,6 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
     {
       status = 1;
       bfd_nonfatal_message (filename, NULL, NULL, NULL);
-      return;
     }
 
   filename = bfd_get_filename (ibfd);
@@ -2333,9 +2340,9 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
     {
       status = 1;
       bfd_nonfatal_message (filename, NULL, NULL, NULL);
-      return;
     }
 
+ cleanup_and_exit:
   /* Delete all the files that we opened.  */
   for (l = list; l != NULL; l = l->next)
     {