From: Christos Zoulas Date: Thu, 11 Dec 2014 11:47:08 +0000 (+0000) Subject: PR/405: file -bizL git-2.1.3.tar.xz broke because the xz decompressor X-Git-Tag: FILE5_22~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=abc95cd644418cc5205a8ad07d864f0851ac49df;p=file PR/405: file -bizL git-2.1.3.tar.xz broke because the xz decompressor dies with SIGPIPE when we stop reading from it early. ignore SIGPIPE> --- diff --git a/src/compress.c b/src/compress.c index fa9e07a7..bf938391 100644 --- a/src/compress.c +++ b/src/compress.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: compress.c,v 1.74 2014/10/26 20:23:30 christos Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.75 2014/12/04 15:56:46 christos Exp $") #endif #include "magic.h" @@ -45,6 +45,7 @@ FILE_RCSID("@(#)$File: compress.c,v 1.74 2014/10/26 20:23:30 christos Exp $") #endif #include #include +#include #if !defined(__MINGW32__) && !defined(WIN32) #include #endif @@ -103,10 +104,12 @@ file_zmagic(struct magic_set *ms, int fd, const char *name, size_t i, nsz; int rv = 0; int mime = ms->flags & MAGIC_MIME; + sig_t osigpipe; if ((ms->flags & MAGIC_COMPRESS) == 0) return 0; + osigpipe = signal(SIGPIPE, SIG_IGN); for (i = 0; i < ncompr; i++) { if (nbytes < compr[i].maglen) continue; @@ -133,6 +136,7 @@ file_zmagic(struct magic_set *ms, int fd, const char *name, } } error: + (void)signal(SIGPIPE, osigpipe); free(newbuf); ms->flags |= MAGIC_COMPRESS; return rv;