diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2006-01-25 17:42:09 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2006-01-25 17:42:09 +0000 |
commit | a8177249d03774fb08a2b601a50d2ac83b18739b (patch) | |
tree | 245af51e84af0410d116198fb1e10b715a9d9289 /bin/pax | |
parent | 211c3d1b8162262bc685d158aa7aca08cacc1d0c (diff) |
append without a file list should not corrupt a tar file;
report Rainer Giedat; ok millert@
Diffstat (limited to 'bin/pax')
-rw-r--r-- | bin/pax/ar_subs.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/bin/pax/ar_subs.c b/bin/pax/ar_subs.c index f19d526c10c..11226280e4d 100644 --- a/bin/pax/ar_subs.c +++ b/bin/pax/ar_subs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar_subs.c,v 1.28 2004/04/16 22:50:23 deraadt Exp $ */ +/* $OpenBSD: ar_subs.c,v 1.29 2006/01/25 17:42:08 markus Exp $ */ /* $NetBSD: ar_subs.c,v 1.5 1995/03/21 09:07:06 cgd Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static const char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94"; #else -static const char rcsid[] = "$OpenBSD: ar_subs.c,v 1.28 2004/04/16 22:50:23 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: ar_subs.c,v 1.29 2006/01/25 17:42:08 markus Exp $"; #endif #endif /* not lint */ @@ -397,10 +397,20 @@ wr_archive(ARCHD *arcn, int is_app) return; /* + * if this is not append, and there are no files, we do not write a + * trailer + */ + wr_one = is_app; + + /* * start up the file traversal code and format specific write */ - if ((ftree_start() < 0) || ((*frmt->st_wr)() < 0)) - return; + if (ftree_start() < 0) { + if (is_app) + goto trailer; + if (((*frmt->st_wr)() < 0)) + return; + } wrf = frmt->wr; /* @@ -410,12 +420,6 @@ wr_archive(ARCHD *arcn, int is_app) if (iflag && (name_start() < 0)) return; - /* - * if this is not append, and there are no files, we do not write a - * trailer - */ - wr_one = is_app; - now = time(NULL); /* @@ -543,6 +547,7 @@ wr_archive(ARCHD *arcn, int is_app) break; } +trailer: /* * tell format to write trailer; pad to block boundary; reset directory * mode/access times, and check if all patterns supplied by the user |