aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2014-11-10 14:28:43 +0000
committerNick Clifton <nickc@redhat.com>2014-11-10 14:28:43 +0000
commit5e186ece2feebb46e63ff6bb2d2490aad0d5a724 (patch)
tree6cd2fabe728b0e7cc2340a049478f4edbe1d60e7
parent36e9d67b868c85232ab630514260f0d9c9c6b27b (diff)
downloadgdb-5e186ece2feebb46e63ff6bb2d2490aad0d5a724.zip
gdb-5e186ece2feebb46e63ff6bb2d2490aad0d5a724.tar.gz
gdb-5e186ece2feebb46e63ff6bb2d2490aad0d5a724.tar.bz2
Fix objcopy and strip so that they remove their temporary files even if an error occurs.
PR binutils/17552 * (copy_archive): Clean up temporary files even if an error occurs.
-rw-r--r--binutils/ChangeLog6
-rw-r--r--binutils/objcopy.c21
2 files changed, 20 insertions, 7 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index b1ef9fa..7ed198c 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -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-07 H.J. Lu <hongjiu.lu@intel.com>
* readelf.c (process_dynamic_section): Cast time value to unsigned
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 8454bc6..07794cb 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -2298,8 +2298,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, "/",
@@ -2310,8 +2314,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;
@@ -2353,7 +2361,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)
@@ -2414,7 +2422,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);
@@ -2422,9 +2429,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)
{