diff options
Diffstat (limited to 'src/compress.c')
| -rw-r--r-- | src/compress.c | 19 | 
1 files changed, 15 insertions, 4 deletions
| diff --git a/src/compress.c b/src/compress.c index e968bb452850b..539031e3490b6 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.77 2014/12/12 16:33:01 christos Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.80 2015/06/03 18:21:24 christos Exp $")  #endif  #include "magic.h" @@ -45,7 +45,12 @@ FILE_RCSID("@(#)$File: compress.c,v 1.77 2014/12/12 16:33:01 christos Exp $")  #endif  #include <string.h>  #include <errno.h> +#ifdef HAVE_SIGNAL_H  #include <signal.h> +# ifndef HAVE_SIG_T +typedef void (*sig_t)(int); +# endif /* HAVE_SIG_T */ +#endif   #if !defined(__MINGW32__) && !defined(WIN32)  #include <sys/ioctl.h>  #endif @@ -104,12 +109,16 @@ file_zmagic(struct magic_set *ms, int fd, const char *name,  	size_t i, nsz;  	int rv = 0;  	int mime = ms->flags & MAGIC_MIME; +#ifdef HAVE_SIGNAL_H  	sig_t osigpipe; +#endif  	if ((ms->flags & MAGIC_COMPRESS) == 0)  		return 0; +#ifdef HAVE_SIGNAL_H  	osigpipe = signal(SIGPIPE, SIG_IGN); +#endif  	for (i = 0; i < ncompr; i++) {  		if (nbytes < compr[i].maglen)  			continue; @@ -121,7 +130,8 @@ file_zmagic(struct magic_set *ms, int fd, const char *name,  			if (file_buffer(ms, -1, name, newbuf, nsz) == -1)  				goto error; -			if (mime == MAGIC_MIME || mime == 0) { +			if ((ms->flags & MAGIC_COMPRESS_TRANSP) == 0 && +			    (mime == MAGIC_MIME || mime == 0)) {  				if (file_printf(ms, mime ?  				    " compressed-encoding=" : " (") == -1)  					goto error; @@ -136,7 +146,9 @@ file_zmagic(struct magic_set *ms, int fd, const char *name,  		}  	}  error: +#ifdef HAVE_SIGNAL_H  	(void)signal(SIGPIPE, osigpipe); +#endif  	free(newbuf);  	ms->flags |= MAGIC_COMPRESS;  	return rv; @@ -383,7 +395,6 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,  	int fdin[2], fdout[2];  	int status;  	ssize_t r; -	pid_t pid;  #ifdef BUILTIN_DECOMPRESS          /* FIXME: This doesn't cope with bzip2 */ @@ -397,7 +408,7 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,  		file_error(ms, errno, "cannot create pipe");	  		return NODATA;  	} -	switch (pid = fork()) { +	switch (fork()) {  	case 0:	/* child */  		(void) close(0);  		if (fd != -1) { | 
