From 9c77cb3c382541372b8f5caeaf0caa0e8e7c58f7 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Wed, 11 Nov 2015 04:25:41 +0000 Subject: [PATCH] PR/495: Spurious msooxml match. REG_STARTEND code is not working as it is supposed to, remove it. --- src/softmagic.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/softmagic.c b/src/softmagic.c index 0db72d26..1e4619fc 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.221 2015/09/16 22:37:05 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.222 2015/09/17 01:10:00 christos Exp $") #endif /* lint */ #include "magic.h" @@ -2005,10 +2005,8 @@ magiccheck(struct magic_set *ms, struct magic *m) file_regerror(&rx, rc, ms); v = (uint64_t)-1; } else { - regmatch_t pmatch[1]; + regmatch_t pmatch; size_t slen = ms->search.s_len; -#ifndef REG_STARTEND -#define REG_STARTEND 0 char *copy; if (slen != 0) { copy = malloc(slen); @@ -2025,22 +2023,15 @@ magiccheck(struct magic_set *ms, struct magic *m) search = ms->search.s; copy = NULL; } -#else - search = ms->search.s; - pmatch[0].rm_so = 0; - pmatch[0].rm_eo = slen; -#endif rc = file_regexec(&rx, (const char *)search, - 1, pmatch, REG_STARTEND); -#if REG_STARTEND == 0 + 1, &pmatch, 0); free(copy); -#endif switch (rc) { case 0: - ms->search.s += (int)pmatch[0].rm_so; - ms->search.offset += (size_t)pmatch[0].rm_so; + ms->search.s += (int)pmatch.rm_so; + ms->search.offset += (size_t)pmatch.rm_so; ms->search.rm_len = - (size_t)(pmatch[0].rm_eo - pmatch[0].rm_so); + (size_t)(pmatch.rm_eo - pmatch.rm_so); v = 0; break; -- 2.40.0