]> granicus.if.org Git - file/commitdiff
Restore part of previous logic, that breaks out of the uncompress loop
authorChristos Zoulas <christos@zoulas.com>
Tue, 19 Apr 2016 23:36:36 +0000 (23:36 +0000)
committerChristos Zoulas <christos@zoulas.com>
Tue, 19 Apr 2016 23:36:36 +0000 (23:36 +0000)
if there was a compression match error or not. Separate the return values
to avoid confusion.

src/compress.c

index 0ebc837a69a37a0391d956012e8b45781080e741..2a95f85df8321536df352f5711521a5e8837fe20 100644 (file)
@@ -35,7 +35,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.93 2016/03/31 17:51:12 christos Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.94 2016/04/19 13:39:19 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