From: Christos Zoulas Date: Fri, 7 Nov 2008 17:26:44 +0000 (+0000) Subject: don't walk past the end of buffer causing segv. X-Git-Tag: FILE5_05~279 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=153275488f2c9673222d317f8548ac17b430933b;p=file don't walk past the end of buffer causing segv. --- diff --git a/src/softmagic.c b/src/softmagic.c index e00cf992..b4dcb667 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.130 2008/11/06 23:22:54 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.131 2008/11/07 17:26:44 christos Exp $") #endif /* lint */ #include "magic.h" @@ -1456,6 +1456,8 @@ mget(struct magic_set *ms, const unsigned char *s, case FILE_INDIRECT: if (file_printf(ms, m->desc) == -1) return -1; + if (nbytes < offset) + return 0; return file_softmagic(ms, s + offset, nbytes - offset, BINTEST);