]> granicus.if.org Git - file/commitdiff
limit bytecnt
authorChristos Zoulas <christos@zoulas.com>
Sat, 24 Jan 2015 22:11:25 +0000 (22:11 +0000)
committerChristos Zoulas <christos@zoulas.com>
Sat, 24 Jan 2015 22:11:25 +0000 (22:11 +0000)
src/softmagic.c

index 90634ef58595568729eac8bdc782c4043f3e7698..2cb7ef0701227c545433c57edb096bce047021a2 100644 (file)
@@ -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;