http://mx.gw.com/pipermail/file/2016/001978.html From 26879a2b5ec6880cb46b416880e520c628927abd Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Tue, 19 Apr 2016 23:36:36 +0000 Subject: [PATCH] Restore part of previous logic, that breaks out of the uncompress loop if there was a compression match error or not. Separate the return values to avoid confusion. --- src/compress.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/compress.c b/src/compress.c index 0ebc837..2a95f85 100644 --- a/src/compress.c +++ b/src/compress.c @@ -187,7 +187,7 @@ file_zmagic(struct magic_set *ms, int fd, const char *name, size_t i, nsz; char *rbuf; file_pushbuf_t *pb; - int rv = 0; + int urv, prv, rv = 0; int mime = ms->flags & MAGIC_MIME; #ifdef HAVE_SIGNAL_H sig_t osigpipe; @@ -214,26 +214,26 @@ file_zmagic(struct magic_set *ms, int fd, const char *name, if (!zm) continue; nsz = nbytes; - rv = uncompressbuf(fd, ms->bytes_max, i, buf, &newbuf, &nsz); + urv = uncompressbuf(fd, ms->bytes_max, i, buf, &newbuf, &nsz); DPRINTF("uncompressbuf = %d, %s, %zu\n", rv, (char *)newbuf, nsz); - switch (rv) { + switch (urv) { case OKDATA: case ERRDATA: ms->flags &= ~MAGIC_COMPRESS; - if (rv == ERRDATA) - rv = file_printf(ms, "%s ERROR: %s", + if (urv == ERRDATA) + prv = file_printf(ms, "%s ERROR: %s", methodname(i), newbuf); else - rv = file_buffer(ms, -1, name, newbuf, nsz); - if (rv == -1) + prv = file_buffer(ms, -1, name, newbuf, nsz); + if (prv == -1) goto error; - DPRINTF("rv = %d\n", rv); + rv = 1; if ((ms->flags & MAGIC_COMPRESS_TRANSP) != 0) - break; + goto out; if (mime != MAGIC_MIME && mime != 0) - break; + goto out; if ((file_printf(ms, mime ? " compressed-encoding=" : " (")) == -1) goto error; @@ -261,6 +261,7 @@ file_zmagic(struct magic_set *ms, int fd, const char *name, break; } } +out: DPRINTF("rv = %d\n", rv); #ifdef HAVE_SIGNAL_H -- 2.7.4