From: Christos Zoulas Date: Tue, 19 Apr 2016 23:36:36 +0000 (+0000) Subject: Restore part of previous logic, that breaks out of the uncompress loop X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44dc012e541795a9a8601f22f86f648fbf1b546a;p=file 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. --- diff --git a/src/compress.c b/src/compress.c index cf0f108d..3286510c 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.94 2016/04/19 13:39:19 christos Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.95 2016/04/19 23:36:36 christos Exp $") #endif #include "magic.h" @@ -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