]> granicus.if.org Git - file/commitdiff
Prevent bogus extra encoding output.
authorReuben Thomas <rrt@sc3d.org>
Sun, 21 Jul 2013 21:06:41 +0000 (21:06 +0000)
committerReuben Thomas <rrt@sc3d.org>
Sun, 21 Jul 2013 21:06:41 +0000 (21:06 +0000)
src/compress.c
src/funcs.c

index 22960808d61749f1ae25a341ef0b14d99db79aa1..c30bfcdc6c4aae6f262003d4e5b756fc10d04d6e 100644 (file)
@@ -35,7 +35,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.69 2012/08/26 10:21:37 christos Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.70 2012/11/07 17:54:48 christos Exp $")
 #endif
 
 #include "magic.h"
@@ -121,14 +121,12 @@ file_zmagic(struct magic_set *ms, int fd, const char *name,
                                if (file_printf(ms, mime ?
                                    " compressed-encoding=" : " (") == -1)
                                        goto error;
+                               if (file_buffer(ms, -1, NULL, buf, nbytes) == -1)
+                                       goto error;
+                               if (!mime && file_printf(ms, ")") == -1)
+                                       goto error;
                        }
 
-                       if ((mime == 0 || mime & MAGIC_MIME_ENCODING) &&
-                           file_buffer(ms, -1, NULL, buf, nbytes) == -1)
-                               goto error;
-
-                       if (!mime && file_printf(ms, ")") == -1)
-                               goto error;
                        rv = 1;
                        break;
                }
index f11e94de6d26b82d2f8d691c419decd60eafcb2e..ff55b79c3b170dcca62f29426c7f16cb0995c684 100644 (file)
@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.60 2011/12/08 12:38:24 rrt Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.61 2012/10/30 23:11:51 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -207,7 +207,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((unu
                if ((m = file_zmagic(ms, fd, inname, ubuf, nb)) != 0) {
                        if ((ms->flags & MAGIC_DEBUG) != 0)
                                (void)fprintf(stderr, "zmagic %d\n", m);
-                       goto done;
+                       goto done_encoding;
                }
 #endif
        /* Check if we have a tar file */
@@ -290,6 +290,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((unu
                if (file_printf(ms, "%s", code_mime) == -1)
                        rv = -1;
        }
+ done_encoding:
        free(u8buf);
        if (rv)
                return rv;