summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/file/magic-test.c7
-rw-r--r--usr.bin/file/magic.h3
2 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/file/magic-test.c b/usr.bin/file/magic-test.c
index 1101de18f1e..9d4e11c7567 100644
--- a/usr.bin/file/magic-test.c
+++ b/usr.bin/file/magic-test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: magic-test.c,v 1.17 2016/04/30 21:10:28 nicm Exp $ */
+/* $OpenBSD: magic-test.c,v 1.18 2016/04/30 21:42:11 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -1054,7 +1054,7 @@ static int
magic_test_type_default(__unused struct magic_line *ml,
__unused struct magic_state *ms)
{
- return (1);
+ return (!ms->matched);
}
static int (*magic_test_functions[])(struct magic_line *,
@@ -1219,11 +1219,14 @@ magic_test_line(struct magic_line *ml, struct magic_state *ms)
ml->type_string, ml->test_operator, offset, ms->offset,
ml->result == NULL ? "" : ml->result);
+ ms->matched = 0;
offset = ms->offset;
TAILQ_FOREACH(child, &ml->children, entry) {
ms->offset = offset;
magic_test_line(child, ms);
}
+
+ ms->matched = 1;
return (ml->result != NULL);
}
diff --git a/usr.bin/file/magic.h b/usr.bin/file/magic.h
index e1c9fc1a8fd..47c25598303 100644
--- a/usr.bin/file/magic.h
+++ b/usr.bin/file/magic.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: magic.h,v 1.11 2015/10/05 20:05:52 nicm Exp $ */
+/* $OpenBSD: magic.h,v 1.12 2016/04/30 21:42:11 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -164,6 +164,7 @@ struct magic_state {
const char *base;
size_t size;
size_t offset;
+ int matched;
};
#define MAGIC_TEST_TEXT 0x1