]> granicus.if.org Git - file/commitdiff
don't walk past the end of buffer causing segv.
authorChristos Zoulas <christos@zoulas.com>
Fri, 7 Nov 2008 17:26:44 +0000 (17:26 +0000)
committerChristos Zoulas <christos@zoulas.com>
Fri, 7 Nov 2008 17:26:44 +0000 (17:26 +0000)
src/softmagic.c

index e00cf992428cfc9865b9edd95c3115318fe9d30d..b4dcb6679ea51eb9c398e31960f6441f0b47eb07 100644 (file)
@@ -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);