]> granicus.if.org Git - file/commitdiff
- bytecnt needs to be adjusted by offset
authorChristos Zoulas <christos@zoulas.com>
Tue, 9 Jun 2015 22:17:52 +0000 (22:17 +0000)
committerChristos Zoulas <christos@zoulas.com>
Tue, 9 Jun 2015 22:17:52 +0000 (22:17 +0000)
- always return true from mget() regardless if match() matched. Fixes
  mime printing where we stopped matching the use magic because match
  return 0, since if (print) *returnval = 1; did not execute for mime.

src/softmagic.c

index 9608b968b5f983b6ad93183b4e1a4ce9cacf1c38..15a092f04abe6ab4a91ae447a151771a80e3cbcc 100644 (file)
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.215 2015/05/21 18:25:29 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.216 2015/06/09 22:17:52 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -1107,7 +1107,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
                                bytecnt = nbytes - offset;
 
                        buf = RCAST(const char *, s) + offset;
-                       end = last = RCAST(const char *, s) + bytecnt;
+                       end = last = RCAST(const char *, s) + bytecnt + offset;
                        /* mget() guarantees buf <= last */
                        for (lines = linecnt, b = buf; lines && b < end &&
                             ((b = CAST(const char *,
@@ -1708,7 +1708,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
                    printed_something, need_separator, returnval);
                if (rv != 1)
                    *need_separator = oneed_separator;
-               return rv;
+               return 1;
 
        case FILE_NAME:
                if (ms->flags & MAGIC_NODESC)