From: Christos Zoulas Date: Tue, 1 Apr 2014 15:44:26 +0000 (+0000) Subject: PR/342: Jan Kaluza: Reverse order of evaluation to fix out of bounds read. X-Git-Tag: FILE5_19~73 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4a350ab786b0272ac62f8de2da3ed4d93655d01;p=file PR/342: Jan Kaluza: Reverse order of evaluation to fix out of bounds read. --- diff --git a/src/softmagic.c b/src/softmagic.c index 77270ead..68efd89b 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.181 2014/03/27 18:12:12 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.182 2014/03/28 19:07:08 christos Exp $") #endif /* lint */ #include "magic.h" @@ -235,8 +235,8 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic, if (file_check_mem(ms, ++cont_level) == -1) return -1; - while (magic[magindex+1].cont_level != 0 && - ++magindex < nmagic) { + while (++magindex < nmagic && + magic[magindex].cont_level != 0) { m = &magic[magindex]; ms->line = m->lineno; /* for messages */