]> granicus.if.org Git - file/commitdiff
If we encountered a match (an entry with description) even if we are not
authorChristos Zoulas <christos@zoulas.com>
Tue, 23 Oct 2018 18:34:46 +0000 (18:34 +0000)
committerChristos Zoulas <christos@zoulas.com>
Tue, 23 Oct 2018 18:34:46 +0000 (18:34 +0000)
printing (i.e. we are doing mime or something else), set the return value,
so that we stop searching. This avoids the issue where mime matched later
entries in the magic list, instead of matching nothing (entries with no
mime that would have matched earlier).

src/softmagic.c

index c1ec262444a28b38d64a13431f99880210542fed..ed9ad39c4c60ca76e7e74ebb819e638e8934c8bb 100644 (file)
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.272 2018/10/19 00:33:04 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.273 2018/10/23 18:34:46 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -247,6 +247,8 @@ flush:
                        return e;
                }
 
+               if (*m->desc)
+                       *returnval = 1;
                /*
                 * If we are going to print something, we'll need to print
                 * a blank before we print something else.
@@ -346,6 +348,8 @@ flush:
                                        *returnval = 1;
                                        return e;
                                }
+                               if (*m->desc)
+                                       *returnval = 1;
                                if (print && *m->desc) {
                                        /*
                                         * This continuation matched.  Print
@@ -401,7 +405,7 @@ flush:
                        firstline = 0;
                        *returnval = 1;
                }
-               if ((ms->flags & MAGIC_CONTINUE) == 0 && *printed_something) {
+               if ((ms->flags & MAGIC_CONTINUE) == 0 && *returnval) {
                        return *returnval; /* don't keep searching */
                }
                cont_level = 0;