summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorsobomax <sobomax@FreeBSD.org>2002-02-07 10:38:16 +0000
committersobomax <sobomax@FreeBSD.org>2002-02-07 10:38:16 +0000
commit53e0d06e7be1f92b7d46218c7844a9738dd1e7cf (patch)
tree62bb8d8d64d37db0ed2957e082c977e3fd1a81e8 /gnu
parentfb9c14949aaad6c80e0021e8740cdacee522adef (diff)
downloadFreeBSD-src-53e0d06e7be1f92b7d46218c7844a9738dd1e7cf.zip
FreeBSD-src-53e0d06e7be1f92b7d46218c7844a9738dd1e7cf.tar.gz
When unpacking compressed archive check exit status of the child (gzip or bzip)
and exit with error code if that status != 0. PR: 30876 Submitted by: Simon Gerraty <sig@juniper.net>
Diffstat (limited to 'gnu')
-rw-r--r--gnu/usr.bin/tar/buffer.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/gnu/usr.bin/tar/buffer.c b/gnu/usr.bin/tar/buffer.c
index 992b322..11b33d4 100644
--- a/gnu/usr.bin/tar/buffer.c
+++ b/gnu/usr.bin/tar/buffer.c
@@ -1256,6 +1256,21 @@ close_archive ()
if (f_verify)
verify_volume ();
+#ifndef __MSDOS__
+ /*
+ * Closing the child's pipe before reading EOF guarantees that it
+ * will be unhappy - SIGPIPE, or exit 1.
+ * Either way it can screw us, so play nice.
+ */
+ if (childpid && ar_reading)
+ {
+ char buf[BUFSIZ];
+
+ while ((c = read(archive, buf, sizeof(buf))) > 0)
+ ;
+ }
+#endif
+
if ((c = rmtclose (archive)) < 0)
msg_perror ("Warning: can't close %s(%d,%d)", ar_files[cur_ar_file], archive, c);
@@ -1294,8 +1309,11 @@ close_archive ()
/* Do nothing. */
}
else if (WEXITSTATUS (status))
- msg ("child returned status %d",
- WEXITSTATUS (status));
+ {
+ msg ("child returned status %d",
+ WEXITSTATUS (status));
+ exit (EX_BADARCH);
+ }
}
}
}
OpenPOWER on IntegriCloud