Browse files

update libmagic to 5.13

  • Loading branch information...
1 parent c2ffa29 commit 5fa7d1137df71b83691ff02d8fa9ff713a790811 @mscdex committed Mar 9, 2013
View
2 binding.gyp
@@ -15,7 +15,7 @@
'cflags_c!': [ '-O2' ],
'cflags_c+': [ '-O3' ],
'dependencies': [
- 'deps/libmagic/binding.gyp:libmagic',
+ 'deps/libmagic/libmagic.gyp:libmagic',
],
},
],
View
34 deps/libmagic/ChangeLog
@@ -1,3 +1,37 @@
+2013-02-18 10:39 Christos Zoulas <christos@zoulas.com>
+
+ * add elf reading of debug info to determine if file is stripped
+ (Jan Kaluza)
+ * use pread()
+
+2013-01-25 18:05 Christos Zoulas <christos@zoulas.com>
+
+ * change mime description size from 64 to 80 to accommodate OOXML.
+
+2013-01-11 14:50 Christos Zoulas <christos@zoulas.com>
+
+ * Warn about inconsistent continuation levels.
+ * Change fsmagic to add a space after it prints.
+
+2013-01-10 21:00 Christos Zoulas <christos@zoulas.com>
+
+ * Make getline public so that file can link against it.
+ Perhaps it is better to rename it, or hide it differently.
+ Fixes builds on platforms that do not provide it.
+
+2013-01-07 16:30 Christos Zoulas <christos@zoulas.com>
+
+ * Add SuS d{,1,2,4,8}, u{,1,2,4,8} and document
+ what long, int, short, etc is (Guy Harris)
+
+2013-01-06 11:20 Christos Zoulas <christos@zoulas.com>
+
+ * add magic_version function and constant
+ * Redo memory allocation and de-allocation.
+ (prevents double frees on non mmap platforms)
+ * Fix bug with name/use having to do with passing
+ found state from the parent to the child and back.
+
2012-12-19 8:47 Christos Zoulas <christos@zoulas.com>
* Only print elf capabilities for archs we know (Jan Kaluza)
View
19 deps/libmagic/README
@@ -1,5 +1,5 @@
** README for file(1) Command **
-@(#) $File: README,v 1.43 2010/11/05 17:25:55 rrt Exp $
+@(#) $File: README,v 1.44 2011/03/24 13:03:39 rrt Exp $
Mailing List: file@mx.gw.com
Bug tracker: http://bugs.gw.com/
@@ -68,30 +68,33 @@ src/apprentice.c - parses /etc/magic to learn magic
src/apptype.c - used for OS/2 specific application type magic
src/asprintf.c - replacement for OS's that don't have it.
src/ascmagic.c - third & last set of tests, based on hardwired assumptions.
+src/asctime_r.c - for systems that don't have it.
+src/asprintf.c - for systems that don't have it.
src/cdf.c - parser for Microsoft Compound Document Files
src/cdf_time.c - time converter for CDF.
src/compress.c - handles decompressing files to look inside.
+src/ctime_r.c - for systems that don't have it.
src/encoding.c - handles unicode encodings
src/file.c - the main program
src/file.h - header file
src/fsmagic.c - first set of tests the program runs, based on filesystem info
src/funcs.c - utilility functions
-src/getopt_long.c - used for OS/2 specific application type magic
+src/getopt_long.c - for systems that don't have it.
+src/getline.c - for systems that don't have it.
src/is_tar.c, tar.h - knows about tarchives (courtesy John Gilmore).
src/names.h - header file for ascmagic.c
src/magic.c - the libmagic api
src/print.c - print results, errors, warnings.
src/readcdf.c - CDF wrapper.
src/readelf.[ch] - Stand-alone elf parsing code.
src/softmagic.c - 2nd set of tests, based on /etc/magic
-src/strlcat.c - used for OS/2 specific application type magic
-src/strlcpy.c - used for OS/2 specific application type magic
-src/vasprintf.c - used for OS/2 specific application type magic
-doc/file.1 - man page for the command
-doc/magic.4 - man page for the magic file, courtesy Guy Harris.
+src/strlcat.c - for systems that don't have it.
+src/strlcpy.c - for systems that don't have it.
+src/vasprintf.c - for systems that don't have it.
+doc/file.man - man page for the command
+doc/magic.man - man page for the magic file, courtesy Guy Harris.
Install as magic.4 on USG and magic.5 on V7 or Berkeley; cf Makefile.
Magdir - directory of /etc/magic pieces
-
------------------------------------------------------------------------------
If you submit a new magic entry please make sure you read the following
View
1 deps/libmagic/config/freebsd/config.h
@@ -320,3 +320,4 @@ typedef long int64_t;
#define HAVE_CTIME_R 1
#define HAVE_ASCTIME_R 1
+#define HAVE_PREAD 1
View
1 deps/libmagic/config/linux/config.h
@@ -320,3 +320,4 @@ typedef long int64_t;
#define HAVE_CTIME_R 1
#define HAVE_ASCTIME_R 1
+#define HAVE_PREAD 1
View
1 deps/libmagic/config/mac/config.h
@@ -320,3 +320,4 @@ typedef long int64_t;
#define HAVE_CTIME_R 1
#define HAVE_ASCTIME_R 1
+#define HAVE_PREAD 1
View
33 deps/libmagic/binding.gyp → deps/libmagic/libmagic.gyp
@@ -5,18 +5,19 @@
'type': 'static_library',
'include_dirs': [ '.', 'src', 'pcre' ],
'dependencies': [
- 'pcre/binding.gyp:pcre',
+ 'pcre/pcre.gyp:libpcre',
],
- 'defines': [ 'HAVE_CONFIG_H', 'VERSION="5.12.1"' ],
+ 'defines': [ 'HAVE_CONFIG_H', 'VERSION="5.13"' ],
'conditions': [
[ 'OS=="win"', {
'sources': [
+ 'src/asctime_r.c',
'src/asprintf.c',
+ 'src/ctime_r.c',
+ 'src/getline.c',
+ 'src/pread.c',
'src/strlcat.c',
'src/strlcpy.c',
- 'src/getline.c',
- 'src/asctime_r.c',
- 'src/ctime_r.c',
'src/vasprintf.c',
],
'include_dirs': [ 'msvc', 'config/win' ],
@@ -35,9 +36,7 @@
'include_dirs': [ 'config/mac' ],
}],
[ 'OS=="freebsd"', {
- 'include_dirs': [
- 'config/freebsd',
- ],
+ 'include_dirs': [ 'config/freebsd' ],
}],
],
'cflags!': [ '-O2' ],
@@ -47,21 +46,21 @@
'cflags_c!': [ '-O2' ],
'cflags_c+': [ '-O3' ],
'sources': [
- 'src/magic.c',
'src/apprentice.c',
- 'src/softmagic.c',
+ 'src/apptype.c',
'src/ascmagic.c',
- 'src/encoding.c',
+ 'src/cdf.c',
+ 'src/cdf_time.c',
'src/compress.c',
- 'src/is_tar.c',
- 'src/readelf.c',
- 'src/print.c',
+ 'src/encoding.c',
'src/fsmagic.c',
'src/funcs.c',
- 'src/apptype.c',
- 'src/cdf.c',
- 'src/cdf_time.c',
+ 'src/is_tar.c',
+ 'src/magic.c',
+ 'src/print.c',
'src/readcdf.c',
+ 'src/readelf.c',
+ 'src/softmagic.c',
],
},
]
View
12 deps/libmagic/src/apprentice.c
@@ -32,7 +32,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.188 2013/01/09 15:36:55 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.189 2013/01/11 16:45:23 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -195,6 +195,7 @@ struct type_tbl_s {
static const struct type_tbl_s type_tbl[] = {
# define XX(s) s, (sizeof(s) - 1)
# define XX_NULL "", 0
+ { XX("invalid"), FILE_INVALID, FILE_FMT_NONE },
{ XX("byte"), FILE_BYTE, FILE_FMT_NUM },
{ XX("short"), FILE_SHORT, FILE_FMT_NUM },
{ XX("default"), FILE_DEFAULT, FILE_FMT_STR },
@@ -239,6 +240,8 @@ static const struct type_tbl_s type_tbl[] = {
{ XX("qwdate"), FILE_QWDATE, FILE_FMT_STR },
{ XX("leqwdate"), FILE_LEQWDATE, FILE_FMT_STR },
{ XX("beqwdate"), FILE_BEQWDATE, FILE_FMT_STR },
+ { XX("name"), FILE_NAME, FILE_FMT_NONE },
+ { XX("use"), FILE_USE, FILE_FMT_NONE },
{ XX_NULL, FILE_INVALID, FILE_FMT_NONE },
};
@@ -369,6 +372,7 @@ init_file_tables(void)
file_names[p->type] = p->name;
file_formats[p->type] = p->format;
}
+ assert(p - type_tbl == FILE_NAMES_SIZE);
}
private int
@@ -1655,9 +1659,8 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line,
/*
* Try it as a keyword type prefixed by "u"; match what
* follows the "u". If that fails, try it as an SUS
- * integer type. In either case, it's unsigned.
+ * integer type.
*/
- m->flag |= UNSIGNED;
m->type = get_type(type_tbl, l + 1, &l);
if (m->type == FILE_INVALID) {
/*
@@ -1666,6 +1669,9 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line,
*/
m->type = get_standard_integer_type(l, &l);
}
+ // It's unsigned.
+ if (m->type != FILE_INVALID)
+ m->flag |= UNSIGNED;
} else {
/*
* Try it as a keyword type. If that fails, try it as
View
5 deps/libmagic/src/cdf.c
@@ -35,7 +35,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.50 2012/02/20 22:35:29 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.51 2012/03/20 18:28:02 christos Exp $")
#endif
#include <assert.h>
@@ -296,10 +296,9 @@ cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len)
if (info->i_fd == -1)
return -1;
- if (lseek(info->i_fd, off, SEEK_SET) == (off_t)-1)
return -1;
- if (read(info->i_fd, buf, len) != (ssize_t)len)
+ if (pread(info->i_fd, buf, len, off) != (ssize_t)len)
return -1;
return (ssize_t)len;
View
3 deps/libmagic/src/elfclass.h
@@ -59,7 +59,8 @@
(off_t)elf_getu(swap, elfhdr.e_shoff),
elf_getu16(swap, elfhdr.e_shnum),
(size_t)elf_getu16(swap, elfhdr.e_shentsize),
- fsize, &flags, elf_getu16(swap, elfhdr.e_machine)) == -1)
+ fsize, &flags, elf_getu16(swap, elfhdr.e_machine),
+ (int)elf_getu16(swap, elfhdr.e_shstrndx)) == -1)
return -1;
break;
View
20 deps/libmagic/src/file.h
@@ -27,7 +27,7 @@
*/
/*
* file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.141 2013/01/07 02:11:22 christos Exp $
+ * @(#)$File: file.h,v 1.143 2013/01/25 23:07:19 christos Exp $
*/
#ifndef __file_h__
@@ -161,12 +161,13 @@ typedef unsigned int mode_t;
#endif
#define MAXMAGIS 8192 /* max entries in any one magic file
or directory */
-#define MAXDESC 64 /* max leng of text description/MIME type */
-#define MAXstring 64 /* max leng of "string" types */
+#define MAXDESC 64 /* max len of text description/MIME type */
+#define MAXMIME 80 /* max len of text MIME type */
+#define MAXstring 64 /* max len of "string" types */
#define MAGICNO 0xF11E041C
-#define VERSIONNO 9
-#define FILE_MAGICSIZE 232
+#define VERSIONNO 10
+#define FILE_MAGICSIZE 248
#define FILE_LOAD 0
#define FILE_CHECK 1
@@ -333,9 +334,9 @@ struct magic {
union VALUETYPE value; /* either number or string */
/* Words 17-32 */
char desc[MAXDESC]; /* description */
- /* Words 33-48 */
- char mimetype[MAXDESC]; /* MIME type */
- /* Words 49-50 */
+ /* Words 33-52 */
+ char mimetype[MAXMIME]; /* MIME type */
+ /* Words 53-54 */
char apple[8];
};
@@ -516,6 +517,9 @@ extern char *sys_errlist[];
#define strtoul(a, b, c) strtol(a, b, c)
#endif
+#ifndef HAVE_PREAD
+ssize_t pread(int, void *, size_t, off_t);
+#endif
#ifndef HAVE_VASPRINTF
int vasprintf(char **, const char *, va_list);
#endif
View
16 deps/libmagic/src/pread.c
@@ -0,0 +1,16 @@
+#include "file.h"
+#ifndef lint
+FILE_RCSID("@(#)$File: ctime_r.c,v 1.1 2012/05/15 17:14:36 christos Exp $")
+#endif /* lint */
+#include <fcntl.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+ssize_t
+pread(int fd, void *buf, ssize_t len, off_t off) {
+ if (lseek(fd, off, SEEK_SET) == (off_t)-1)
+ return -1;
+
+ return read(fd, buf, len);
+}
View
112 deps/libmagic/src/readelf.c
@@ -27,7 +27,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.93 2012/10/31 17:03:41 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.95 2013/02/18 15:40:59 christos Exp $")
#endif
#ifdef BUILTIN_ELF
@@ -48,7 +48,7 @@ private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t,
private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t,
off_t, int *, int);
private int doshn(struct magic_set *, int, int, int, off_t, int, size_t,
- off_t, int *, int);
+ off_t, int *, int, int);
private size_t donote(struct magic_set *, void *, size_t, size_t, int,
int, size_t, int *);
@@ -133,19 +133,21 @@ getu64(int swap, uint64_t value)
#define elf_getu32(swap, value) getu32(swap, value)
#ifdef USE_ARRAY_FOR_64BIT_TYPES
# define elf_getu64(swap, array) \
- ((swap ? ((uint64_t)elf_getu32(swap, array[0])) << 32 : elf_getu32(swap, array[0])) + \
- (swap ? elf_getu32(swap, array[1]) : ((uint64_t)elf_getu32(swap, array[1]) << 32)))
+ ((swap ? ((uint64_t)elf_getu32(swap, array[0])) << 32 \
+ : elf_getu32(swap, array[0])) + \
+ (swap ? elf_getu32(swap, array[1]) : \
+ ((uint64_t)elf_getu32(swap, array[1]) << 32)))
#else
# define elf_getu64(swap, value) getu64(swap, value)
#endif
#define xsh_addr (clazz == ELFCLASS32 \
- ? (void *) &sh32 \
- : (void *) &sh64)
+ ? (void *)&sh32 \
+ : (void *)&sh64)
#define xsh_sizeof (clazz == ELFCLASS32 \
- ? sizeof sh32 \
- : sizeof sh64)
-#define xsh_size (clazz == ELFCLASS32 \
+ ? sizeof(sh32) \
+ : sizeof(sh64))
+#define xsh_size (size_t)(clazz == ELFCLASS32 \
? elf_getu32(swap, sh32.sh_size) \
: elf_getu64(swap, sh64.sh_size))
#define xsh_offset (off_t)(clazz == ELFCLASS32 \
@@ -154,12 +156,15 @@ getu64(int swap, uint64_t value)
#define xsh_type (clazz == ELFCLASS32 \
? elf_getu32(swap, sh32.sh_type) \
: elf_getu32(swap, sh64.sh_type))
+#define xsh_name (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, sh32.sh_name) \
+ : elf_getu32(swap, sh64.sh_name))
#define xph_addr (clazz == ELFCLASS32 \
? (void *) &ph32 \
: (void *) &ph64)
#define xph_sizeof (clazz == ELFCLASS32 \
- ? sizeof ph32 \
- : sizeof ph64)
+ ? sizeof(ph32) \
+ : sizeof(ph64))
#define xph_type (clazz == ELFCLASS32 \
? elf_getu32(swap, ph32.p_type) \
: elf_getu32(swap, ph64.p_type))
@@ -175,8 +180,8 @@ getu64(int swap, uint64_t value)
? elf_getu32(swap, ph32.p_filesz) \
: elf_getu64(swap, ph64.p_filesz)))
#define xnh_addr (clazz == ELFCLASS32 \
- ? (void *) &nh32 \
- : (void *) &nh64)
+ ? (void *)&nh32 \
+ : (void *)&nh64)
#define xph_memsz (size_t)((clazz == ELFCLASS32 \
? elf_getu32(swap, ph32.p_memsz) \
: elf_getu64(swap, ph64.p_memsz)))
@@ -196,8 +201,8 @@ getu64(int swap, uint64_t value)
? prpsoffsets32[i] \
: prpsoffsets64[i])
#define xcap_addr (clazz == ELFCLASS32 \
- ? (void *) &cap32 \
- : (void *) &cap64)
+ ? (void *)&cap32 \
+ : (void *)&cap64)
#define xcap_sizeof (clazz == ELFCLASS32 \
? sizeof cap32 \
: sizeof cap64)
@@ -299,7 +304,7 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
{
Elf32_Phdr ph32;
Elf64_Phdr ph64;
- size_t offset;
+ size_t offset, len;
unsigned char nbuf[BUFSIZ];
ssize_t bufsize;
@@ -313,11 +318,7 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
* Loop through all the program headers.
*/
for ( ; num; num--) {
- if (lseek(fd, off, SEEK_SET) == (off_t)-1) {
- file_badseek(ms);
- return -1;
- }
- if (read(fd, xph_addr, xph_sizeof) == -1) {
+ if (pread(fd, xph_addr, xph_sizeof, off) == -1) {
file_badread(ms);
return -1;
}
@@ -335,13 +336,8 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
* This is a PT_NOTE section; loop through all the notes
* in the section.
*/
- if (lseek(fd, xph_offset, SEEK_SET) == (off_t)-1) {
- file_badseek(ms);
- return -1;
- }
- bufsize = read(fd, nbuf,
- ((xph_filesz < sizeof(nbuf)) ? xph_filesz : sizeof(nbuf)));
- if (bufsize == -1) {
+ len = xph_filesz < sizeof(nbuf) ? xph_filesz : sizeof(nbuf);
+ if ((bufsize = pread(fd, nbuf, len, xph_offset)) == -1) {
file_badread(ms);
return -1;
}
@@ -851,28 +847,41 @@ static const cap_desc_t cap_desc_386[] = {
private int
doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
- size_t size, off_t fsize, int *flags, int mach)
+ size_t size, off_t fsize, int *flags, int mach, int strtab)
{
Elf32_Shdr sh32;
Elf64_Shdr sh64;
int stripped = 1;
void *nbuf;
- off_t noff, coff;
+ off_t noff, coff, name_off;
uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilites */
uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilites */
+ char name[50];
if (size != xsh_sizeof) {
if (file_printf(ms, ", corrupted section header size") == -1)
return -1;
return 0;
}
+ /* Read offset of name section to be able to read section names later */
+ if (pread(fd, xsh_addr, xsh_sizeof, off + size * strtab) == -1) {
+ file_badread(ms);
+ return -1;
+ }
+ name_off = xsh_offset;
+
for ( ; num; num--) {
- if (lseek(fd, off, SEEK_SET) == (off_t)-1) {
- file_badseek(ms);
+ /* Read the name of this section. */
+ if (pread(fd, name, sizeof(name), name_off + xsh_name) == -1) {
+ file_badread(ms);
return -1;
}
- if (read(fd, xsh_addr, xsh_sizeof) == -1) {
+ name[sizeof(name) - 1] = '\0';
+ if (strcmp(name, ".debug_info") == 0)
+ stripped = 0;
+
+ if (pread(fd, xsh_addr, xsh_sizeof, off) == -1) {
file_badread(ms);
return -1;
}
@@ -897,31 +906,23 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
/* Things we can determine when we seek */
switch (xsh_type) {
case SHT_NOTE:
- if ((nbuf = malloc((size_t)xsh_size)) == NULL) {
+ if ((nbuf = malloc(xsh_size)) == NULL) {
file_error(ms, errno, "Cannot allocate memory"
" for note");
return -1;
}
- if ((noff = lseek(fd, (off_t)xsh_offset, SEEK_SET)) ==
- (off_t)-1) {
+ if (pread(fd, nbuf, xsh_size, xsh_offset) == -1) {
file_badread(ms);
free(nbuf);
return -1;
}
- if (read(fd, nbuf, (size_t)xsh_size) !=
- (ssize_t)xsh_size) {
- free(nbuf);
- file_badread(ms);
- return -1;
- }
noff = 0;
for (;;) {
if (noff >= (off_t)xsh_size)
break;
noff = donote(ms, nbuf, (size_t)noff,
- (size_t)xsh_size, clazz, swap, 4,
- flags);
+ xsh_size, clazz, swap, 4, flags);
if (noff == 0)
break;
}
@@ -939,8 +940,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
goto skip;
}
- if (lseek(fd, (off_t)xsh_offset, SEEK_SET) ==
- (off_t)-1) {
+ if (lseek(fd, xsh_offset, SEEK_SET) == (off_t)-1) {
file_badseek(ms);
return -1;
}
@@ -1063,7 +1063,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
const char *shared_libraries = "";
unsigned char nbuf[BUFSIZ];
ssize_t bufsize;
- size_t offset, align;
+ size_t offset, align, len;
if (size != xph_sizeof) {
if (file_printf(ms, ", corrupted program header size") == -1)
@@ -1072,13 +1072,8 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
}
for ( ; num; num--) {
- if (lseek(fd, off, SEEK_SET) == (off_t)-1) {
- file_badseek(ms);
- return -1;
- }
-
- if (read(fd, xph_addr, xph_sizeof) == -1) {
- file_badread(ms);
+ if (pread(fd, xph_addr, xph_sizeof, off) == -1) {
+ file_badread(ms);
return -1;
}
@@ -1116,12 +1111,9 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
* This is a PT_NOTE section; loop through all the notes
* in the section.
*/
- if (lseek(fd, xph_offset, SEEK_SET) == (off_t)-1) {
- file_badseek(ms);
- return -1;
- }
- bufsize = read(fd, nbuf, ((xph_filesz < sizeof(nbuf)) ?
- xph_filesz : sizeof(nbuf)));
+ len = xph_filesz < sizeof(nbuf) ? xph_filesz
+ : sizeof(nbuf);
+ bufsize = pread(fd, nbuf, len, xph_offset);
if (bufsize == -1) {
file_badread(ms);
return -1;
View
9 deps/libmagic/src/softmagic.c
@@ -32,7 +32,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.157 2013/01/04 16:37:54 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.158 2013/01/06 20:22:16 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -997,7 +997,7 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
private void
mdebug(uint32_t offset, const char *str, size_t len)
{
- (void) fprintf(stderr, "mget @%d: ", offset);
+ (void) fprintf(stderr, "mget/%zu @%d: ", len, offset);
file_showstr(stderr, str, len);
(void) fputc('\n', stderr);
(void) fputc('\n', stderr);
@@ -1126,10 +1126,13 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
struct mlist ml;
if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o),
- (uint32_t)(nbytes - o), count) == -1)
+ (uint32_t)nbytes, count) == -1)
return -1;
if ((ms->flags & MAGIC_DEBUG) != 0) {
+ fprintf(stderr, "mget(type=%d, flag=%x, offset=%u, o=%zu, "
+ "nbytes=%zu, count=%u)\n", m->type, m->flag, offset, o,
+ nbytes, count);
mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE));
#ifndef COMPILE_ONLY
file_mdump(m);
View
BIN magic/magic.mgc
Binary file not shown.

0 comments on commit 5fa7d11

Please sign in to comment.