[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] [PATCH] Refuse to create archive for non-existent members
From: |
Connor Behan |
Subject: |
[Bug-tar] [PATCH] Refuse to create archive for non-existent members |
Date: |
Mon, 23 Sep 2013 16:45:54 -0700 |
* src/create.c (dump_file0): Open archive when the existence check is
first passed.
(create_archive): Close archive if the existence check was passed at
least once.
---
src/create.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/create.c b/src/create.c
index e14e13d..a56f28f 100644
--- a/src/create.c
+++ b/src/create.c
@@ -1327,9 +1327,6 @@ create_archive (void)
trivial_link_count = name_count <= 1 && ! dereference_option;
- open_archive (ACCESS_WRITE);
- buffer_write_global_xheader ();
-
if (incremental_option)
{
size_t buffer_size = 1000;
@@ -1405,11 +1402,15 @@ create_archive (void)
dump_file (0, name, name);
}
- write_eot ();
- close_archive ();
- finish_deferred_unlinks ();
- if (listed_incremental_option)
- write_directory_file ();
+ /* If none of the passed files existed, the archive was never opened. */
+ if (archive > 0)
+ {
+ write_eot ();
+ close_archive ();
+ finish_deferred_unlinks ();
+ if (listed_incremental_option)
+ write_directory_file ();
+ }
}
@@ -1676,6 +1677,13 @@ dump_file0 (struct tar_stat_info *st, char const *name,
char const *p)
return;
}
+ /* The archive should be opened when we first verify that it will not be
empty. */
+ if (archive <= 0)
+ {
+ open_archive (ACCESS_WRITE);
+ buffer_write_global_xheader ();
+ }
+
st->archive_file_size = original_size = st->stat.st_size;
st->atime = get_stat_atime (&st->stat);
st->mtime = get_stat_mtime (&st->stat);
--
1.8.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-tar] [PATCH] Refuse to create archive for non-existent members,
Connor Behan <=