]> granicus.if.org Git - file/commitdiff
PR/342: Jan Kaluza: Reverse order of evaluation to fix out of bounds read.
authorChristos Zoulas <christos@zoulas.com>
Tue, 1 Apr 2014 15:44:26 +0000 (15:44 +0000)
committerChristos Zoulas <christos@zoulas.com>
Tue, 1 Apr 2014 15:44:26 +0000 (15:44 +0000)
src/softmagic.c

index 77270eadba0f89d47c06ad45731d3a9faa37ea84..68efd89be4dcdd2b38f8f9d8af9026abd8410e87 100644 (file)
@@ -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 */