From: Christos Zoulas Date: Tue, 26 Feb 2013 18:24:43 +0000 (+0000) Subject: - avoid 0 offset causing an infinite loop. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e82bbb863de7675c4194e089fbf0dfad0a3f986;p=file - avoid 0 offset causing an infinite loop. - XXX: should limit indirect nesting. --- diff --git a/src/softmagic.c b/src/softmagic.c index 038a1ffc..9e8324cc 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.159 2013/02/17 22:28:27 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.160 2013/02/26 18:24:43 christos Exp $") #endif /* lint */ #include "magic.h" @@ -1617,6 +1617,12 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m, if (m->flag & INDIROFFADD) { offset += ms->c.li[cont_level-1].off; + if (offset == 0) { + if ((ms->flags & MAGIC_DEBUG) != 0) + fprintf(stderr, + "indirect *zero* offset\n"); + return 0; + } if ((ms->flags & MAGIC_DEBUG) != 0) fprintf(stderr, "indirect +offs=%u\n", offset); }