diff options
author | Christos Zoulas <christos@zoulas.com> | 2021-09-03 13:17:52 +0000 |
---|---|---|
committer | Christos Zoulas <christos@zoulas.com> | 2021-09-03 13:17:52 +0000 |
commit | bf877852846e1e0f2fe0d63b0d43620053adaa7e (patch) | |
tree | a0f794fc23d047d2f50231e3e46c75704127abf2 | |
parent | 2e48f028e670659d4674ce28604ed6ac5acba70d (diff) | |
download | file-git-bf877852846e1e0f2fe0d63b0d43620053adaa7e.tar.gz |
Don't short-circuit the results of the search; set v so that we can do
relationship matching properly.
-rw-r--r-- | src/softmagic.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/softmagic.c b/src/softmagic.c index 073e2a18..8d2d7b72 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.314 2021/07/01 07:51:35 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.315 2021/09/03 13:17:52 christos Exp $") #endif /* lint */ #include "magic.h" @@ -2153,8 +2153,10 @@ magiccheck(struct magic_set *ms, struct magic *m) idx = ms->search.s_len; found = CAST(const char *, memmem(ms->search.s, idx, m->value.s, slen)); - if (!found) - return 0; + if (!found) { + v = 1; + break; + } idx = found - ms->search.s; ms->search.offset += idx; ms->search.rm_len = ms->search.s_len - idx; @@ -2163,8 +2165,10 @@ magiccheck(struct magic_set *ms, struct magic *m) #endif for (idx = 0; m->str_range == 0 || idx < m->str_range; idx++) { - if (slen + idx > ms->search.s_len) - return 0; + if (slen + idx > ms->search.s_len) { + v = 1; + break; + } v = file_strncmp(m->value.s, ms->search.s + idx, slen, ms->search.s_len - idx, m->str_flags); |