From e60dc715160ce8023f8248cc9fc243dc4b4581e0 Mon Sep 17 00:00:00 2001 From: Christos Zoulas <christos@zoulas.com> Date: Tue, 23 Oct 2018 18:34:46 +0000 Subject: [PATCH] If we encountered a match (an entry with description) even if we are not 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 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/softmagic.c b/src/softmagic.c index c1ec2624..ed9ad39c 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -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; -- 2.40.0