From: Christos Zoulas Date: Sat, 24 Jan 2015 22:11:25 +0000 (+0000) Subject: limit bytecnt X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f719d52cd04f1e58c6ab306e16fe6de6cea2708;p=file limit bytecnt --- diff --git a/src/softmagic.c b/src/softmagic.c index 90634ef5..2cb7ef07 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.211 2015/01/09 19:27:41 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.212 2015/01/24 22:11:25 christos Exp $") #endif /* lint */ #include "magic.h" @@ -1103,10 +1103,8 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, bytecnt = m->str_range; } - if (bytecnt == 0) - bytecnt = 8192; - if (bytecnt > nbytes) - bytecnt = nbytes; + if (bytecnt == 0 || bytecnt > nbytes - offset) + bytecnt = nbytes - offset; buf = RCAST(const char *, s) + offset; end = last = RCAST(const char *, s) + bytecnt;