diff options
author | Tim Kientzle <kientzle@gmail.com> | 2011-11-05 19:34:57 -0400 |
---|---|---|
committer | Tim Kientzle <kientzle@gmail.com> | 2011-11-05 19:34:57 -0400 |
commit | 6fa664e048bd225a80515aecc5f3e6275569121d (patch) | |
tree | 3095b266eb31ffa458d15c51e21cc6eacb6d86ae /cpio | |
parent | 03c054cf578b83f96239d3a88ad6293c9014f0c7 (diff) | |
download | libarchive-6fa664e048bd225a80515aecc5f3e6275569121d.tar.gz |
Mask SIGPIPE for libarchive test, tar, and cpio.
As reported at:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=641265
The SIGPIPE occurs when feeding data through a decompression
program; the external program may see an end-of-data marker
and exit before we've finished feeding it all of the data.
(This happens when the data has garbage padding at the end.)
We want to catch and ignore the EPIPE since we can still
read the data coming out of the decompression program.
SVN-Revision: 3751
Diffstat (limited to 'cpio')
-rw-r--r-- | cpio/cpio.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cpio/cpio.c b/cpio/cpio.c index 6a09412c..ff5a1c60 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -56,6 +56,9 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.15 2008/12/06 07:30:40 kientzle #ifdef HAVE_PWD_H #include <pwd.h> #endif +#ifdef HAVE_SIGNAL_H +#include <signal.h> +#endif #ifdef HAVE_STDARG_H #include <stdarg.h> #endif @@ -136,6 +139,16 @@ main(int argc, char *argv[]) cpio->buff = buff; cpio->buff_size = sizeof(buff); +#if defined(HAVE_SIGACTION) && defined(SIGPIPE) + { /* Ignore SIGPIPE signals. */ + struct sigaction sa; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = SIG_IGN; + sigaction(SIGPIPE, &sa, NULL); + } +#endif + /* Need lafe_progname before calling lafe_warnc. */ if (*argv == NULL) lafe_progname = "bsdcpio"; |