compile
.git
.gitignore
+.config_*.cache
--- /dev/null
+*~
+*.[oa]
+*.l[ao]
+
+.deps
+.libs
+
+Makefile
+Makefile.in
+
+/aclocal.m4
+/autom4te.cache
+/compile
+/config.cache
+/config.guess
+/config.h
+/config.h.in
+/config.log
+/config.status
+/config.sub
+/configure
+/depcomp
+/install-sh
+/libtool
+/ltmain.sh
+/m4
+/missing
+/stamp-h1
+
+/doc/file.1
+/doc/libmagic.3
+/doc/magic.4
+
+/magic/magic.mgc
+
+/src/file
+/src/magic.h
+2016-06-13 19:40 Christos Zoulas <christos@zoulas.com>
+
+ * release 5.28
+ * fix leak on allocation failure
+
+2016-06-01 1:20 Christos Zoulas <christos@zoulas.com>
+
+ * PR/555: Avoid overflow for offset > nbytes
+ * PR/550: Segv on DER parsing:
+ - use the correct variable for length
+ - set offset to 0 on failure.
+
2016-05-13 12:00 Christos Zoulas <christos@zoulas.com>
* release 5.27
AC_DEFINE([ELFCORE], 1, [Define for ELF core file support])
])
+AC_MSG_CHECKING(for zlib support)
+AC_ARG_ENABLE(zlib,
+[AS_HELP_STRING([--disable-zlib], [disable zlib compression support @<:@default=auto@:>@])])
+AC_MSG_RESULT($enable_zlib)
+
AC_MSG_CHECKING(for file formats in man section 5)
AC_ARG_ENABLE(fsect-man5,
[ --enable-fsect-man5 enable file formats in man section 5],
AC_CHECK_HEADERS(stddef.h utime.h wchar.h wctype.h limits.h)
AC_CHECK_HEADERS(getopt.h err.h xlocale.h signal.h)
AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
-AC_CHECK_HEADERS(zlib.h)
+if test "$enable_zlib" != "no"; then
+ AC_CHECK_HEADERS(zlib.h)
+fi
AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[
#ifdef HAVE_SIGNAL_H
#include <signal.h>
AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf)
dnl Checks for libraries
-AC_CHECK_LIB(z,gzopen)
+if test "$enable_zlib" != "no"; then
+ AC_CHECK_LIB(z, gzopen)
+fi
if test "$MINGW" = 1; then
AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW]))
fi
dnl See if we are cross-compiling
AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
+dnl Final sanity checks
+if test "$enable_zlib" = "yes"; then
+ if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then
+ AC_MSG_ERROR([zlib support requested but not found])
+ fi
+elif test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then
+ AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support])
+fi
+
AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile])
AC_OUTPUT
-.\" $File: file.man,v 1.119 2016/03/14 02:39:46 christos Exp $
+.\" $File: file.man,v 1.120 2016/03/31 17:51:12 christos Exp $
.Dd March 13, 2016
.Dt FILE __CSECTION__
.Os
Consults magic files.
.It tar
Examines tar files.
+.It text
+A synonym for
+.Sq ascii .
.El
.It Fl Fl extension
Print a slash-separated list of valid extensions for the file type found.
--- /dev/null
+
+#------------------------------------------------------------------------------
+# $File: animation,v 1.57 2015/11/29 22:11:07 christos Exp $
+# ber: file(1) magic for several BER formats used in the mobile
+# telecommunications industry (Georg Sauthoff)
+
+# The file formats are standardized by the GSMA (GSM association).
+# They are specified via ASN.1 schemas and some prose. Basic encoding
+# rules (BER) is the used encoding. The formats are used for exchanging
+# call data records (CDRs) between mobile operators and associated
+# parties for roaming clearing purposes and fraud detection.
+
+# The magic file covers:
+
+# - TAP files (TD.57) - CDR batches and notifications
+# - RAP files (TD.32) - return batches and acknowledgements
+# - NRT files (TD.35) - CDR batches for 'near real time' processing
+
+#
+# TAP 3 Files
+# TAP -> Transferred Account Procedure
+# cf. http://www.gsma.com/newsroom/wp-content/uploads/TD.57-v32.31.pdf
+# TransferBatch short tag
+0 byte 0x61
+# BatchControlInfo short tag
+>&1 search/b5 \x64
+# Sender long tag #TAP 3.x (BER encoded)
+>>&1 search/b8 \x5f\x81\x44
+# <SpecificationVersionNumber>3</><ReleaseVersionNumber> block
+>>>&64 search/b64 \x5f\x81\x49\x01\x03\x5f\x81\x3d\x01
+>>>>&0 byte x TAP 3.%d Batch (TD.57, Transferred Account)
+
+# Notification short tag
+0 byte 0x62
+# Sender long tag
+>2 search/b8 \x5f\x81\x44
+# <SpecificationVersionNumber>3</><ReleaseVersionNumber> block
+>>&64 search/b64 \x5f\x81\x49\x01\x03\x5f\x81\x3d\x01
+>>>&0 byte x TAP 3.%d Notification (TD.57, Transferred Account)
+
+
+# NRT Files
+# NRT a.k.a. NRTRDE
+0 byte 0x61
+# <SpecificationVersionNumber>2</><ReleaseVersionNumber> block
+>&1 search/b8 \x5f\x29\x01\x02\x5f\x25\x01
+>>&0 byte x NRT 2.%d (TD.35, Near Real Time Roaming Data Exchange)
+
+# RAP Files
+# cf. http://www.gsma.com/newsroom/wp-content/uploads/TD.32-v6.11.pdf
+# Long ReturnBatch tag
+0 string \x7f\x84\x16
+# Long RapBatchControlInfo tag
+>&1 search/b8 \x7f\x84\x19
+# <SpecificationVersionNumber>3</><ReleaseVersionNumber> block
+>>&64 search/b64 \x5f\x81\x49\x01\x03\x5f\x81\x3d\x01
+# <RapSpecificationVersionNumber>1</><RapReleaseVersionNumber> block
+>>>&1 string/b \x5f\x84\x20\x01\x01\x5f\x84\x1f\x01
+>>>>&0 byte x RAP 1.%d Batch (TD.32, Returned Account Procedure),
+>>>&0 byte x TAP 3.%d
+
+# Long Acknowledgement tag
+0 string \x7f\x84\x17
+# Long Sender tag
+>&1 search/b5 \x5f\x81\x44 RAP Acknowledgement (TD.32, Returned Account Procedure)
#------------------------------------------------------------------------------
-# $File: c-lang,v 1.21 2015/10/29 18:45:05 christos Exp $
+# $File: c-lang,v 1.22 2015/10/29 18:49:11 christos Exp $
# c-lang: file(1) magic for C and related languages programs
#
# The strength is to beat standard HTML
!:strength + 30
!:mime text/x-c++
0 regex \^class[\ \t\n]+ C++ source text
-!:strength + 30
+# But class is reduced to avoid beating php (Jens Schleusener)
+!:strength + 13
!:mime text/x-c++
0 regex \^public: C++ source text
!:strength + 30
#------------------------------------------------------------------------------
-# $File: console,v 1.24 2016/03/23 15:29:20 christos Exp $
+# $File: console,v 1.25 2016/04/18 20:22:10 christos Exp $
# Console game magic
# Toby Deshane <hac@shoelace.digivill.net>
>4 lelong <16 UNIF v%d format NES ROM image
#------------------------------------------------------------------------------
+# fds: file(1) magic for Famciom Disk System disk images
+# Reference: http://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format
+# From: David Korth <gerbilsoft@gerbilsoft.com>
+# TODO: Check "Disk info block" and get info from that in addition to the optional header.
+
+# Disk info block. (block 1)
+0 name nintendo-fds-disk-info-block
+>1 string *NINTENDO-HVC* Famicom Disk System disk image:
+>23 byte !1 FMC-
+>23 byte 1 FSC-
+>16 string x \b%.3s
+>15 byte x \b, mfr 0x%02X
+>20 byte x (Rev.%02u)
+
+# Headered version.
+0 string FDS\x1A
+>0x11 string *NINTENDO-HVC*
+>>0x10 use nintendo-fds-disk-info-block
+>4 byte 1 (%u side)
+>4 byte !1 (%u sides)
+
+# Unheadered version.
+1 string *NINTENDO-HVC*
+>0 use nintendo-fds-disk-info-block
+
+#------------------------------------------------------------------------------
# gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format
# Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header
#
0x1C belong 0xC2339F3D Nintendo GameCube disc image:
>0 use nintendo-gcn-disc-common
+# Type: Nintendo GameCube embedded disc image
+# Commonly found on demo discs.
+# From: David Korth <gerbilsoft@gerbilsoft.com>
+# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8
+0 belong 0xAE0F38A2
+>0x0C belong 0x00100000
+>>(8.L+0x1C) belong 0xC2339F3D Nintendo GameCube embedded disc image:
+>>>(8.L) use nintendo-gcn-disc-common
+
# Type: Nintendo Wii disc image
# From: David Korth <gerbilsoft@gerbilsoft.com>
# Reference: http://wiibrew.org/wiki/Wii_Disc
# Nintendo 3DS file formats.
#
-# Type: Nintendo 3DS "NCCH" header.
-# Contained within either a CXI executable or an NCSD image.
-# From: David Korth <gerbilsoft@gerbilsoft.com>
-# Reference: https://www.3dbrew.org/wiki/NCCH
-0 name nintendo-3ds-NCCH
->0x100 string NCCH
->>0x150 string >\0 \b: "%.16s"
->>0x112 leshort x (v%u)
->>0x18C byte 2 (New3DS only)
-
# Type: Nintendo 3DS "NCSD" image. (game cards and eMMC)
# From: David Korth <gerbilsoft@gerbilsoft.com>
# Reference: https://www.3dbrew.org/wiki/NCSD
0x100 string NCSD
>0x118 lequad 0 Nintendo 3DS Game Card image
->>0x1000 use nintendo-3ds-NCCH
+# NCCH header for partition 0. (game data)
+>>0x1150 string >\0 \b: "%.16s"
+>>0x312 byte x (Rev.%02u)
+>>0x118C byte 2 (New3DS only)
>>0x18D byte 0 (inner device)
>>0x18D byte 1 (Card1)
>>0x18D byte 2 (Card2)
>0x118 bequad 0x0102020202000000 Nintendo 3DS eMMC dump (Old3DS)
>0x118 bequad 0x0102020203000000 Nintendo 3DS eMMC dump (New3DS)
+# Nintendo 3DS version code.
+# Reference: https://www.3dbrew.org/wiki/Titles
+# Format: leshort containing three fields:
+# - 6-bit: Major
+# - 6-bit: Minor
+# - 4-bit: Revision
+# NOTE: Only supporting major/minor versions from 0-15 right now.
+# NOTE: Should be prefixed with "v".
+0 name nintendo-3ds-version-code
+# Raw version.
+>0 leshort x \b%u,
+# Major version.
+>0 leshort&0xFC00 0x0000 0
+>0 leshort&0xFC00 0x0400 1
+>0 leshort&0xFC00 0x0800 2
+>0 leshort&0xFC00 0x0C00 3
+>0 leshort&0xFC00 0x1000 4
+>0 leshort&0xFC00 0x1400 5
+>0 leshort&0xFC00 0x1800 6
+>0 leshort&0xFC00 0x1C00 7
+>0 leshort&0xFC00 0x2000 8
+>0 leshort&0xFC00 0x2400 9
+>0 leshort&0xFC00 0x2800 10
+>0 leshort&0xFC00 0x2C00 11
+>0 leshort&0xFC00 0x3000 12
+>0 leshort&0xFC00 0x3400 13
+>0 leshort&0xFC00 0x3800 14
+>0 leshort&0xFC00 0x3C00 15
+# Minor version.
+>0 leshort&0x03F0 0x0000 \b.0
+>0 leshort&0x03F0 0x0010 \b.1
+>0 leshort&0x03F0 0x0020 \b.2
+>0 leshort&0x03F0 0x0030 \b.3
+>0 leshort&0x03F0 0x0040 \b.4
+>0 leshort&0x03F0 0x0050 \b.5
+>0 leshort&0x03F0 0x0060 \b.6
+>0 leshort&0x03F0 0x0070 \b.7
+>0 leshort&0x03F0 0x0080 \b.8
+>0 leshort&0x03F0 0x0090 \b.9
+>0 leshort&0x03F0 0x00A0 \b.10
+>0 leshort&0x03F0 0x00B0 \b.11
+>0 leshort&0x03F0 0x00C0 \b.12
+>0 leshort&0x03F0 0x00D0 \b.13
+>0 leshort&0x03F0 0x00E0 \b.14
+>0 leshort&0x03F0 0x00F0 \b.15
+# Revision.
+>0 leshort&0x000F x \b.%u
+
# Type: Nintendo 3DS "NCCH" container.
# https://www.3dbrew.org/wiki/NCCH
-0x100 string NCCH Nintendo 3DS
->0x18D byte&2 0 File Archive (CFA)
->0x18D byte&2 2 Executable Image (CXI)
->0 use nintendo-3ds-NCCH
+0x100 string NCCH Nintendo 3DS
+>0x18D byte&2 0 File Archive (CFA)
+>0x18D byte&2 2 Executable Image (CXI)
+>0x150 string >\0 \b: "%.16s"
+>0x18D byte 0x05
+>>0x10E leshort x (Old3DS System Update v
+>>0x10E use nintendo-3ds-version-code
+>>0x10E leshort x \b)
+>0x18D byte 0x15
+>>0x10E leshort x (New3DS System Update v
+>>0x10E use nintendo-3ds-version-code
+>>0x10E leshort x \b)
+>0x18D byte !0x05
+>>0x18D byte !0x15
+>>>0x112 byte x (v
+>>>0x112 use nintendo-3ds-version-code
+>>>0x112 byte x \b)
+>0x18C byte 2 (New3DS only)
# Type: Nintendo 3DS "SMDH" file. (application description)
# From: David Korth <gerbilsoft@gerbilsoft.com>
--- /dev/null
+
+#------------------------------------------------------------------------------
+# $File: animation,v 1.57 2015/11/29 22:11:07 christos Exp $
+# xoverage: file(1) magic for test coverage data
+
+# File formats used to store test coverage data
+# 2016-05-21, Georg Sauthoff <mail@georg.so>
+
+
+# - GCC gcno - written by GCC at compile time when compiling with
+# gcc -ftest-coverage
+# - GCC gcda - written by a program that was compiled with
+# gcc -fprofile-arcs
+# - LLVM raw profiles - generated by a program compiled with
+# clang -fprofile-instr-generate -fcoverage-mapping ...
+# - LLVM indexed profiles - generated by
+# llvm-profdata
+# - GCOV reports, i.e. the annotated source code
+# - LCOV trace files, i.e. aggregated GCC profiles
+#
+# GCC coverage tracefiles
+# .gcno file are created during compile time,
+# while data collected during runtime is stored in .gcda files
+# cf. gcov-io.h
+# https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/Gcov-Data-Files.html
+# Examples:
+# Fedora 23/x86-64/gcc-5.3.1: 6f 6e 63 67 52 33 30 35
+# Debian 8 PPC64/gcc-4.9.2 : 67 63 6e 6f 34 30 39 2a
+0 lelong 0x67636e6f GCC gcno coverage (-ftest-coverage),
+>&3 byte x version %c.
+>&1 byte x \b%c
+
+# big endian
+0 belong 0x67636e6f GCC gcno coverage (-ftest-coverage),
+>&0 byte x version %c.
+>&2 byte x \b%c (big-endian)
+
+# Examples:
+# Fedora 23/x86-64/gcc-5.3.1: 61 64 63 67 52 33 30 35
+# Debian 8 PPC64/gcc-4.9.2 : 67 63 64 61 34 30 39 2a
+0 lelong 0x67636461 GCC gcda coverage (-fprofile-arcs),
+>&3 byte x version %c.
+>&1 byte x \b%c
+
+# big endian
+0 belong 0x67636461 GCC gcda coverage (-fprofile-arcs),
+>&0 byte x version %c.
+>&2 byte x \b%c (big-endian)
+
+
+# LCOV tracefiles
+# cf. http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php
+0 string TN:
+>&0 search/64 \nSF:/ LCOV coverage tracefile
+
+
+# Coverage reports generated by gcov
+# i.e. source code annoted with coverage information
+0 string \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Source:
+>&0 search/128 \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Graph:
+>>&0 search/128 \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Data: GCOV coverage report
+
+
+# LLVM coverage files
+
+# raw data after running a program compiled with:
+# `clang -fprofile-instr-generate -fcoverage-mapping ...`
+# default name: default.profraw
+# magic is: \xFF lprofr \x81
+# cf. http://llvm.org/docs/doxygen/html/InstrProfData_8inc_source.html
+0 lequad 0xff6c70726f667281 LLVM raw profile data,
+>&0 byte x version %d
+
+# big endian
+0 bequad 0xff6c70726f667281 LLVM raw profile data,
+>&7 byte x version %d (big-endian)
+
+
+# LLVM indexed instruction profile (as generated by llvm-profdata)
+# magic is: reverse(\xFF lprofi \x81)
+# cf. http://llvm.org/docs/CoverageMappingFormat.html
+# http://llvm.org/docs/doxygen/html/namespacellvm_1_1IndexedInstrProf.html
+# http://llvm.org/docs/CommandGuide/llvm-cov.html
+# http://llvm.org/docs/CommandGuide/llvm-profdata.html
+0 lequad 0x8169666f72706cff LLVM indexed profile data,
+>&0 byte x version %d
+
+# big endian
+0 bequad 0x8169666f72706cff LLVM indexed profile data,
+>&7 byte x version %d (big-endian)
+
#------------------------------------------------------------------------------
-# $File: database,v 1.47 2016/01/08 00:41:02 christos Exp $
+# $File: database,v 1.48 2016/04/14 20:34:28 christos Exp $
# database: file(1) magic for various databases
#
# extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk)
!:ext pan
# database name
>>>5 pstring x \b, "%s"
+
+#
+#
+# askSam Database by Stefan A. Haubenthal <polluks@web.de>
+0 string askw40\0 askSam DB
+
+#
+#
+# MUIbase Database Tool by Stefan A. Haubenthal <polluks@web.de>
+0 string MBSTV\040 MUIbase DB
+>6 string x version %s
#------------------------------------------------------------------------------
-# $File: elf,v 1.68 2014/09/19 19:05:57 christos Exp $
+# $File: elf,v 1.69 2015/06/16 17:23:08 christos Exp $
# elf: file(1) magic for ELF executables
#
# We have to check the byte order flag to see what byte order all the
>>0 use elf-le
>5 byte 2 MSB
>>0 use \^elf-le
-# Up to now only 0, 1 and 2 are defined; I've seen a file with 0x83, it seemed
-# like proper ELF, but extracting the string had bad results.
->4 byte <0x80
->>8 string >\0 (%s)
->8 string \0
->>7 byte 0 (SYSV)
->>7 byte 1 (HP-UX)
->>7 byte 2 (NetBSD)
->>7 byte 3 (GNU/Linux)
->>7 byte 4 (GNU/Hurd)
->>7 byte 5 (86Open)
->>7 byte 6 (Solaris)
->>7 byte 7 (Monterey)
->>7 byte 8 (IRIX)
->>7 byte 9 (FreeBSD)
->>7 byte 10 (Tru64)
->>7 byte 11 (Novell Modesto)
->>7 byte 12 (OpenBSD)
->8 string \2
->>7 byte 13 (OpenVMS)
->>7 byte 97 (ARM)
->>7 byte 255 (embedded)
+>7 byte 0 (SYSV)
+>7 byte 1 (HP-UX)
+>7 byte 2 (NetBSD)
+>7 byte 3 (GNU/Linux)
+>7 byte 4 (GNU/Hurd)
+>7 byte 5 (86Open)
+>7 byte 6 (Solaris)
+>7 byte 7 (Monterey)
+>7 byte 8 (IRIX)
+>7 byte 9 (FreeBSD)
+>7 byte 10 (Tru64)
+>7 byte 11 (Novell Modesto)
+>7 byte 12 (OpenBSD)
+>7 byte 13 (OpenVMS)
+>7 byte 14 (HP NonStop Kernel)
+>7 byte 15 (AROS Research Operating System)
+>7 byte 16 (FenixOS)
+>7 byte 17 (Nuxi CloudABI)
+>7 byte 97 (ARM)
+>7 byte 255 (embedded)
#------------------------------------------------------------------------------
-# $File: msdos,v 1.104 2015/11/09 16:59:45 christos Exp $
+# $File: msdos,v 1.105 2016/03/03 18:58:14 christos Exp $
# msdos: file(1) magic for MS-DOS files
#
0 string/b \102\101\050\000\000\000\056\000\000\000\000\000\000\000 Icon for MS Windows
# Windows icons
-0 name ico-dir
-# not entirely accurate, the number of icons is part of the header
->0 byte 1 - 1 icon
->0 ubyte >1 - %d icons
->2 byte 0 \b, 256x
->2 byte !0 \b, %dx
->3 byte 0 \b256
->3 byte !0 \b%d
->4 ubyte !0 \b, %d colors
-
+# Update: Joerg Jenderek
+# URL: https://en.wikipedia.org/wiki/CUR_(file_format)
+# Note: similiar to Windows CURsor. container for BMP (only DIB part) or PNG
0 belong 0x00000100
>9 byte 0
->>0 byte x MS Windows icon resource
-!:mime image/x-icon
->>4 use ico-dir
+>>0 byte x
+>>0 use cur-ico-dir
>9 ubyte 0xff
->>0 byte x MS Windows icon resource
-!:mime image/x-icon
->>4 use ico-dir
+>>0 byte x
+>>0 use cur-ico-dir
+# displays number of icons and information for icon or cursor
+0 name cur-ico-dir
+# skip some Lotus 1-2-3 worksheets, CYCLE.PIC and keep Windows cursors with
+# 1st data offset = dir header size + n * dir entry size = 6 + n * 10h = ?6h
+>18 ulelong &0x00000006
+# skip remaining worksheets, because valid only for DIB image (40) or PNG image (\x89PNG)
+>>(18.l) ulelong x MS Windows
+>>>0 ubelong 0x00000100 icon resource
+#!:mime image/vnd.microsoft.icon
+!:mime image/x-icon
+!:ext ico
+>>>>4 uleshort x - %d icon
+# plural s
+>>>>4 uleshort >1 \bs
+# 1st icon
+>>>>0x06 use ico-entry
+# 2nd icon
+>>>>4 uleshort >1
+>>>>>0x16 use ico-entry
+>>>0 ubelong 0x00000200 cursor resource
+#!:mime image/x-cur
+!:mime image/x-win-bitmap
+!:ext cur
+>>>>4 uleshort x - %d icon
+>>>>4 uleshort >1 \bs
+# 1st cursor
+>>>>0x06 use cur-entry
+#>>>>0x16 use cur-entry
+# display information of one cursor entry
+0 name cur-entry
+>0 use cur-ico-entry
+>4 uleshort x \b, hotspot @%dx
+>6 uleshort x \b%d
+# display information of one icon entry
+0 name ico-entry
+>0 use cur-ico-entry
+# normally 0 1 but also found 14
+>4 uleshort >1 \b, %d planes
+# normally 0 1 but also found some 3, 4, some 6, 8, 24, many 32, two 256
+>6 uleshort >1 \b, %d bits/pixel
+# display shared information of cursor or icon entry
+0 name cur-ico-entry
+>0 byte =0 \b, 256x
+>0 byte !0 \b, %dx
+>1 byte =0 \b256
+>1 byte !0 \b%d
+# number of colors in palette
+>2 ubyte !0 \b, %d colors
+# reserved 0 FFh
+#>3 ubyte x \b, reserved %x
+#>8 ulelong x \b, image size %d
+# offset of PNG or DIB image
+#>12 ulelong x \b, offset 0x%x
+# PNG header (\x89PNG)
+>(12.l) ubelong =0x89504e47
+>>&-4 indirect x \b with
+# DIB image
+>(12.l) ubelong !0x89504e47
+#>>&-4 use dib-image
# Windows non-animated cursors
-0 name cur-dir
-# not entirely accurate, the number of icons is part of the header
->0 byte 1 - 1 icon
->0 ubyte >1 - %d icons
->2 byte 0 \b, 256x
->2 byte !0 \b, %dx
->3 byte 0 \b256
->3 byte !0 \b%d
->6 uleshort x \b, hotspot @%dx
->8 uleshort x \b%d
-
+# Update: Joerg Jenderek
+# URL: https://en.wikipedia.org/wiki/CUR_(file_format)
+# Note: similiar to Windows ICOn. container for BMP ( only DIB part)
+# GRR: line below is too general as it catches also Lotus 1-2-3 files
0 belong 0x00000200
>9 byte 0
->>0 byte x MS Windows cursor resource
-!:mime image/x-cur
->>4 use cur-dir
+>>0 use cur-ico-dir
>9 ubyte 0xff
->>0 byte x MS Windows cursor resource
-!:mime image/x-cur
->>4 use cur-dir
+>>0 use cur-ico-dir
# .chr files
0 string/b PK\010\010BGI Borland font
#------------------------------------------------------------------------------
# msx: file(1) magic for the MSX Home Computer
-# v1.1
+# v1.3
# Fabio R. Schmidlin <sd-snatcher@users.sourceforge.net>
############## MSX Music file formats ##############
>>5 uleshort 0
>>>3 uleshort >0x013D MSX Graph Saurus compressed image
-# Maki-chan Graphic format
-0 string/b MAKI02\ \ Maki-chan image,
->8 byte x system ID: %c
->9 byte x \b%c
->10 byte x \b%c
->11 byte x \b%c,
->13 search/0x200 \x1A
-# >>&3 ubyte 0 , video mode: PC-98 400 lines, 16 analog colors
-# >>&3 ubyte 1 , video mode: MSX SC7, 16 analog colors
-# >>&3 ubyte 2 , video mode: VM-98 400 lines, 8 analog colors
-# >>&3 ubyte 3 , video mode: PC-88 analog, 200 lines, 8 analog colors
-# >>&3 ubyte 4 , video mode: 400 lines, 16 digital colors
-# >>&3 ubyte 5 , video mode: 200 lines, 16 digital colors
-# >>&3 ubyte 6 , video mode: old PC-98 digital 400 lines, 8 colors
-# >>&3 ubyte 7 , video mode: PC-88 400 lines, 8 digital colors
->>&8 uleshort+1 x %dx
->>&10 uleshort+1 x \b%d,
->>&3 ubyte&0x82 0x80 256 colors
->>&3 ubyte&0x82 0x00 16 colors
->>&3 ubyte&0x82 0x01 8 colors
->>&3 ubyte&0x04 4 digital
->>&3 ubyte&0x04 0 analog
->>&3 ubyte&0x01 1 \b, 2:1 dot aspect ratio
-
-# Japanese PIC file
-0 string/b PIC\x1A
->4 lelong 0 Japanese PIC image file
-
# MSX G9B image file
0 string/b G9B
>1 uleshort 11
############## Other MSX file formats ##############
-# MSX ROMs
+# MSX internal ROMs
+0 ubeshort 0xF3C3
+>2 uleshort <0x4000
+>>8 ubyte 0xC3
+>>>9 uleshort <0x4000
+>>>>0x0B ubeshort 0x00C3
+>>>>>0x0D uleshort <0x4000
+>>>>>>0x0F ubeshort 0x00C3
+>>>>>>>0x11 uleshort <0x4000
+>>>>>>>>0x13 ubeshort 0x00C3
+>>>>>>>>>0x15 uleshort <0x4000
+>>>>>>>>>>0x50 ubyte 0xC3
+>>>>>>>>>>>0x51 uleshort <0x4000
+>>>>>>>>>>>>(9.s) ubyte 0xC3
+>>>>>>>>>>>>>&0 uleshort >0x4000
+>>>>>>>>>>>>>>&0 ubyte 0xC3 MSX BIOS+BASIC
+>>>>>>>>>>>>>>>0x002D ubyte+1 <3 \b. version=MSX%d
+>>>>>>>>>>>>>>>0x002D ubyte 2 \b, version=MSX2+
+>>>>>>>>>>>>>>>0x002D ubyte 3 \b, version=MSX Turbo-R
+>>>>>>>>>>>>>>>0x002D ubyte >3 \b, version=Unknown MSX %d version
+>>>>>>>>>>>>>>>0x0006 ubyte x \b, VDP.DR=0x%2x
+>>>>>>>>>>>>>>>0x0007 ubyte x \b, VDP.DW=0x%2x
+>>>>>>>>>>>>>>>0x002B ubyte&0xF 0 \b, charset=Japanese
+>>>>>>>>>>>>>>>0x002B ubyte&0xF 1 \b, charset=International
+>>>>>>>>>>>>>>>0x002B ubyte&0xF 2 \b, charset=Korean
+>>>>>>>>>>>>>>>0x002B ubyte&0xF >2 \b, charset=Unknown id:%d
+>>>>>>>>>>>>>>>0x002B ubyte&0x70 0x00 \b, date format=Y-M-D
+>>>>>>>>>>>>>>>0x002B ubyte&0x70 0x10 \b, date format=M-D-Y
+>>>>>>>>>>>>>>>0x002B ubyte&0x70 0x20 \b, date format=D-M-Y
+>>>>>>>>>>>>>>>0x002B ubyte&0x80 0x00 \b, vfreq=60Hz
+>>>>>>>>>>>>>>>0x002B ubyte&0x80 0x80 \b, vfreq=50Hz
+>>>>>>>>>>>>>>>0x002C ubyte&0x0F 0 \b, keyboard=Japanese
+>>>>>>>>>>>>>>>0x002C ubyte&0x0F 1 \b, keyboard=International
+>>>>>>>>>>>>>>>0x002C ubyte&0x0F 2 \b, keyboard=French
+>>>>>>>>>>>>>>>0x002C ubyte&0x0F 3 \b, keyboard=UK
+>>>>>>>>>>>>>>>0x002C ubyte&0x0F 4 \b, keyboard=German
+>>>>>>>>>>>>>>>0x002C ubyte&0x0F 5 \b, keyboard=Unknown id:%d
+>>>>>>>>>>>>>>>0x002C ubyte&0x0F 6 \b, keyboard=Spanish
+>>>>>>>>>>>>>>>0x002C ubyte&0x0F >6 \b, keyboard=Unknown id:%d
+>>>>>>>>>>>>>>>0x002C ubyte&0xF0 0x00 \b, basic=Japanese
+>>>>>>>>>>>>>>>0x002C ubyte&0xF0 0x10 \b, basic=International
+>>>>>>>>>>>>>>>0x002C ubyte&0xF0 >0x10 \b, basic=Unknown id:%d
+>>>>>>>>>>>>>>>0x002E ubyte&1 1 \b, built-in MIDI
+
+
+0 string/b CD
+>2 uleshort >0x10
+>>2 uleshort <0x4000
+>>>4 uleshort <0x4000
+>>>>6 uleshort <0x4000
+>>>>>8 ubyte 0xC3
+>>>>>>9 uleshort <0x4000
+>>>>>>>0x10 ubyte 0xC3
+>>>>>>>>0x11 uleshort <0x4000
+>>>>>>>>>0x14 ubyte 0xC3
+>>>>>>>>>>0x15 uleshort <0x4000 MSX2/2+/TR SubROM
+
+0 string \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
+>0x5F0 ubequad 0x8282828244380000
+>>0x150 ubyte 0x38
+>>>0x170 string \20\20\20
+>>>>0x1E32 string ())
+>>>>>0x2130 ubequad 0xA5A5594924231807
+>>>>>0x2138 ubequad 0x4A4A3424488830C0 MSX Kanji Font
+
+
+
+# MSX extension ROMs
0 string/b AB
>2 uleshort 0x0010 MSX ROM
>>2 uleshort x \b, init=0x%4x
->>4 uleshort >0 \b, stat=0x%4x
->>6 uleshort >0 \b, dev=0x%4x
+>>4 uleshort >0 \b, stahdl=0x%4x
+>>6 uleshort >0 \b, devhdl=0x%4x
>>8 uleshort >0 \b, bas=0x%4x
>2 uleshort 0x4010 MSX ROM
>>2 uleshort x \b, init=0x%04x
->>4 uleshort >0 \b, stat=0x%04x
->>6 uleshort >0 \b, dev=0x%04x
+>>4 uleshort >0 \b, stahdl=0x%04x
+>>6 uleshort >0 \b, devhdl=0x%04x
>>8 uleshort >0 \b, bas=0x%04x
>2 uleshort 0x8010 MSX ROM
>>2 uleshort x \b, init=0x%04x
->>4 uleshort >0 \b, stat=0x%04x
->>6 uleshort >0 \b, dev=0x%04x
+>>4 uleshort >0 \b, stahdl=0x%04x
+>>6 uleshort >0 \b, devhdl=0x%04x
>>8 uleshort >0 \b, bas=0x%04x
+0 string/b AB\0\0
+>6 uleshort 0
+>>4 uleshort >0x400F MSX-BASIC extension ROM
+>>>4 uleshort >0 \b, stahdl=0x%04x
+>>>6 uleshort >0 \b, devhdl=0x%04x
+>>>0x1C string OPLL \b, MSX-Music
+>>>>0x18 string PAC2 \b (external)
+>>>>0x18 string APRL \b (internal)
+
+0 string/b AB\0\0\0\0
+>6 uleshort >0x400F MSX device BIOS
+>>6 uleshort >0 \b, devhdl=0x%04x
+
0 string/b AB
#>2 string 5JSuperLAYDOCK MSX Super Laydock ROM
#>3 string @HYDLIDE3MSX MSX Hydlide-3 ROM
#>3 string @3\x80IA862 Golvellius MSX1 ROM
->2 uleshort >10
->>10 string \0\0\0\0\0\0 MSX ROM
->>>0x10 string YZ\0\0\0\0 Konami Game Master 2 MSX ROM
->>>0x10 string CD \b, Konami RC-
->>>>0x12 ubyte x \b%d
->>>>0x13 ubyte/16 x \b%d
->>>>0x13 ubyte&0xF x \b%d
->>>0x10 string EF \b, Konami RC-
->>>>0x12 ubyte x \b%d
->>>>0x13 ubyte/16 x \b%d
->>>>0x13 ubyte&0xF x \b%d
->>>2 uleshort x \b, init=0x%04x
->>>4 uleshort >0 \b, stat=0x%04x
->>>6 uleshort >0 \b, dev=0x%04x
->>>8 uleshort >0 \b, bas=0x%04x
->2 uleshort 0
->>4 uleshort 0
->>>6 uleshort 0
->>>>8 uleshort >0 MSX BASIC program in ROM, bas=0x%04x
+>2 uleshort >15
+>>2 uleshort <0xC000
+>>>8 string \0\0\0\0\0\0\0\0
+>>>>(2.s&0x3FFF) uleshort >0 MSX ROM
+>>>>>0x10 string YZ\0\0\0\0 Konami Game Master 2 MSX ROM
+>>>>>0x10 string CD \b, Konami RC-
+>>>>>>0x12 ubyte x \b%d
+>>>>>>0x13 ubyte/16 x \b%d
+>>>>>>0x13 ubyte&0xF x \b%d
+>>>>>0x10 string EF \b, Konami RC-
+>>>>>>0x12 ubyte x \b%d
+>>>>>>0x13 ubyte/16 x \b%d
+>>>>>>0x13 ubyte&0xF x \b%d
+>>>>>2 uleshort x \b, init=0x%04x
+>>>>>4 uleshort >0 \b, stahdl=0x%04x
+>>>>>6 uleshort >0 \b, devhdl=0x%04x
+>>>>>8 uleshort >0 \b, bas=0x%04x
+>>>2 uleshort 0
+>>>>4 uleshort 0
+>>>>>6 uleshort 0
+>>>>>>8 uleshort >0 MSX BASIC program in ROM, bas=0x%04x
0x4000 string/b AB
->0x4002 uleshort >0x4010
->>0x400A string \0\0\0\0\0\0 MSX MegaROM with nonstandard page order
+>0x4002 uleshort >0x400F
+>>0x400A string \0\0\0\0\0\0 MSX ROM with nonstandard page order
>>0x4002 uleshort x \b, init=0x%04x
->>0x4004 uleshort >0 \b, stat=0x%04x
->>0x4006 uleshort >0 \b, dev=0x%04x
+>>0x4004 uleshort >0 \b, stahdl=0x%04x
+>>0x4006 uleshort >0 \b, devhdl=0x%04x
>>0x4008 uleshort >0 \b, bas=0x%04x
0x8000 string/b AB
->0x8002 uleshort >0x4010
->>0x800A string \0\0\0\0\0\0 MSX MegaROM with nonstandard page order
+>0x8002 uleshort >0x400F
+>>0x800A string \0\0\0\0\0\0 MSX ROM with nonstandard page order
>>0x8002 uleshort x \b, init=0x%04x
->>0x8004 uleshort >0 \b, stat=0x%04x
->>0x8006 uleshort >0 \b, dev=0x%04x
+>>0x8004 uleshort >0 \b, stahdl=0x%04x
+>>0x8006 uleshort >0 \b, devhdl=0x%04x
>>0x8008 uleshort >0 \b, bas=0x%04x
-0x3C000 string AB
->0x3C008 string/b \0\0\0\0\0\0\0\0 MSX MegaROM with nonstandard page order
+0x3C000 string/b AB
+>0x3C008 string \0\0\0\0\0\0\0\0 MSX MegaROM with nonstandard page order
>>0x3C002 uleshort x \b, init=0x%04x
->>0x3C004 uleshort >0 \b, stat=0x%04x
->>0x3C006 uleshort >0 \b, dev=0x%04x
+>>0x3C004 uleshort >0 \b, stahdl=0x%04x
+>>0x3C006 uleshort >0 \b, devhdl=0x%04x
>>0x3C008 uleshort >0 \b, bas=0x%04x
# MSX BIN file
>>1 uleshort >0x8000 MSX-BASIC program
# MSX .CAS file
-0 string \x1F\xA6\xDE\xBA\xCC\x13\x7D\x74 MSX cassette archive
+0 string/b \x1F\xA6\xDE\xBA\xCC\x13\x7D\x74 MSX cassette archive
# Mega-Assembler file
0 byte 0xFE
--- /dev/null
+#------------------------------------------------------------------------------
+# pc88: file(1) magic for the NEC Home Computer
+# v1.0
+# Fabio R. Schmidlin <sd-snatcher@users.sourceforge.net>
+
+# PC88 2D disk image
+0x20 ulelong&0xFFFFFEFF 0x2A0
+>0x10 string \0\0\0\0\0\0\0\0\0\0
+>>0x280 string \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
+>>>0x1A ubyte&0xEF 0
+>>>>0x1B ubyte&0x8F 0
+>>>>>0x1B ubyte&70 <0x40
+>>>>>>0x1C ulelong >0x21
+>>>>>>>0 regex [[:print:]]* NEC PC-88 disk image, name=%s
+>>>>>>>>0x1B ubyte 0 \b, media=2D
+>>>>>>>>0x1B ubyte 0x10 \b, media=2DD
+>>>>>>>>0x1B ubyte 0x20 \b, media=2HD
+>>>>>>>>0x1B ubyte 0x30 \b, media=1D
+>>>>>>>>0x1B ubyte 0x40 \b, media=1DD
+>>>>>>>>0x1A ubyte 0x10 \b, write-protected
+
+
+
+
--- /dev/null
+#------------------------------------------------------------------------------
+# pc98: file(1) magic for the MSX Home Computer
+# v1.0
+# Fabio R. Schmidlin <sd-snatcher@users.sourceforge.net>
+
+# Maki-chan v1 Graphic format
+# The image resolution should be X=(44.L - 40.L) and Y=(46.L - 42.L), but I couldn't find a way to do so
+# http://www.jisyo.com/viewer/faq/maki_tech.htm
+0 string/b MAKI01 Maki-chan v1.
+>6 ubyte|0x20 x \b%c image
+>8 ubelong >0x40404040 \b, system ID:
+>>8 byte x %c
+>>9 byte x \b%c
+>>10 byte x \b%c
+>>11 byte x \b%c
+>44 ubeshort x \b, %dx
+>46 ubeshort x \b%d
+>38 ubeshort&2 0 \b, 16 paletted RGB colors
+>38 ubeshort&2 2 \b, 8 fixed RGB colors
+>38 ubeshort&1 1 \b, 2:1 dot aspect ratio
+
+# Maki-chan v2 Graphic format
+# http://www.jisyo.com/viewer/faq/mag_tech.htm
+# http://mooncore.eu/bunny/txt/makichan.htm
+# http://metanest.jp/mag/mag.xhtml
+0 string/b MAKI02\ \ Maki-chan v2 image,
+>8 byte x system ID: %c
+>9 byte x \b%c
+>10 byte x \b%c
+>11 byte x \b%c,
+>13 search/0x200 \x1A
+#Maki-chan video modes are a bit messy and seems to have been expanded over the years without too much planing:
+#1) When offset1(ubeshort) !=0x0344:
+# 1.1) And offset3(ubyte).b7=0:
+# - b0=pixel aspect ratio: 1=2:1 (note: this ignores that the machine's 1:1 pixel aspect ratio isn't really 1:1)
+# - b1=number of colors: 0=16 colors, 1=8 colors
+# - b2=Palette or fixed colors flag (called "analog" and "digital" in the doc): 0=Paletted, 1=Fixed colors encoded directly in the pixel data
+# 1.2) And offset3(ubyte).B7=1:
+# - b0=256 paletted colors
+# - b1=256 fixed colors using the MSX SCR8 palette
+#2) When offset1(ubeshort) =0x0344:
+# - 256x212 image with 19268 YJK colors. The usual resolution and color information fields from the file must be ignored
+>>&1 ubeshort 0x0344 256x212, 19268 fixed YJK colors
+>>&1 ubeshort !0x0344
+>>>&5 uleshort+1 x %dx
+>>>&7 uleshort+1 x \b%d,
+>>>&0 ubyte&0x86 0x00 16 paletted RGB colors
+>>>&0 ubyte&0x86 0x02 8 paletted RGB colors
+>>>&0 ubyte&0x86 0x04 16 fixed RGB colors
+>>>&0 ubyte&0x86 0x06 8 fixed RGB colors
+>>>&0 ubyte&0x81 0x80 256 paletted RGB colors
+>>>&0 ubyte&0x81 0x81 256 fixed MSX-SCR8 colors
+>>>&0 ubyte&0x01 1 \b, 2:1 dot aspect ratio
+
+# XLD4 (Q4) picture
+11 string/b MAJYO XLD4(Q4) picture
+
+# Yanagisawa Pi picture
+#0 string Pi\x1A\0 Yanagisawa Pi picture
+#>3 search/0x200 \x04
+0 string Pi
+>2 search/0x200 \x1A
+>>&0 ubyte 0
+>>>&3 ubyte 4 Yanagisawa Pi 16 color picture,
+>>>&4 byte x system ID: %c
+>>>&5 byte x \b%c
+>>>&6 byte x \b%c
+>>>&7 byte x \b%c,
+>>>&10 ubeshort x %dx
+>>>&12 ubeshort x \b%d
+>>>&3 ubyte 8 Yanagisawa Pi 256 color picture
+>>>&4 byte x system ID: %c
+>>>&5 byte x \b%c
+>>>&6 byte x \b%c
+>>>&7 byte x \b%c,
+>>>&10 ubeshort x %dx
+>>>&12 ubeshort x \b%d
#------------------------------------------------------------------------------
-# $File: perl,v 1.23 2015/02/14 17:53:29 christos Exp $
+# $File: perl,v 1.24 2015/03/27 17:58:58 christos Exp $
# perl: file(1) magic for Larry Wall's perl language.
#
# The `eval' lines recognizes an outrageously clever hack.
!:mime text/x-perl
0 search/1024 eval\ '(exit\ $?0)'\ &&\ eval\ 'exec Perl script text
!:mime text/x-perl
-0 search/1024 #!/usr/bin/env\ perl Perl script text executable
+0 string #!/usr/bin/env\ perl Perl script text executable
!:mime text/x-perl
-0 search/1024 #!\ /usr/bin/env\ perl Perl script text executable
+0 string #!\ /usr/bin/env\ perl Perl script text executable
!:mime text/x-perl
-0 search/1024 #!
+0 string #!
>0 regex \^#!.*/bin/perl([[:space:]].*)*$ Perl script text executable
!:mime text/x-perl
--- /dev/null
+#------------------------------------------------------------------------------
+# x68000: file(1) magic for the Sharp Home Computer
+# v1.0
+# Fabio R. Schmidlin <sd-snatcher@users.sourceforge.net>
+
+# Yanagisawa PIC picture
+0 string PIC
+>3 search/0x200 \x1A
+>>&0 search/0x200 \x0
+>>>&0 ubyte 0 Yanagisawa PIC image file,
+>>>>&0 ubyte&15 0 model: X68000,
+>>>>&0 ubyte&15 1 model: PC-88VA,
+>>>>&0 ubyte&15 2 model: FM-TOWNS,
+>>>>&0 ubyte&15 3 model: MAC,
+>>>>&0 ubyte&15 15 model: Generic,
+>>>>&3 ubeshort x %dx
+>>>>&5 ubeshort x \b%d,
+>>>>&1 ubeshort 4 colors: 16
+>>>>&1 ubeshort 8 colors: 256
+>>>>&1 ubeshort 12 colors: 4096
+>>>>&1 ubeshort 15 colors: 32768
+>>>>&1 ubeshort 16 colors: 65536
+>>>>&1 ubeshort >16 colors: %d-bit
+
+
#
-# $File: Makefile.am,v 1.112 2016/02/14 15:48:18 christos Exp $
+# $File: Makefile.am,v 1.115 2016/06/05 00:25:58 christos Exp $
#
MAGIC_FRAGMENT_BASE = Magdir
MAGIC_DIR = $(top_srcdir)/magic
$(MAGIC_FRAGMENT_DIR)/att3b \
$(MAGIC_FRAGMENT_DIR)/audio \
$(MAGIC_FRAGMENT_DIR)/basis \
+$(MAGIC_FRAGMENT_DIR)/ber \
$(MAGIC_FRAGMENT_DIR)/bflt \
$(MAGIC_FRAGMENT_DIR)/bioinformatics \
$(MAGIC_FRAGMENT_DIR)/blackberry \
$(MAGIC_FRAGMENT_DIR)/compress \
$(MAGIC_FRAGMENT_DIR)/console \
$(MAGIC_FRAGMENT_DIR)/convex \
+$(MAGIC_FRAGMENT_DIR)/coverage \
$(MAGIC_FRAGMENT_DIR)/cracklib \
$(MAGIC_FRAGMENT_DIR)/ctags \
$(MAGIC_FRAGMENT_DIR)/ctf \
$(MAGIC_FRAGMENT_DIR)/pascal \
$(MAGIC_FRAGMENT_DIR)/pbf \
$(MAGIC_FRAGMENT_DIR)/pbm \
+$(MAGIC_FRAGMENT_DIR)/pc88 \
+$(MAGIC_FRAGMENT_DIR)/pc98 \
$(MAGIC_FRAGMENT_DIR)/pdf \
$(MAGIC_FRAGMENT_DIR)/pdp \
$(MAGIC_FRAGMENT_DIR)/perl \
$(MAGIC_FRAGMENT_DIR)/wireless \
$(MAGIC_FRAGMENT_DIR)/wordprocessors \
$(MAGIC_FRAGMENT_DIR)/wsdl \
+$(MAGIC_FRAGMENT_DIR)/x68000 \
$(MAGIC_FRAGMENT_DIR)/xdelta \
$(MAGIC_FRAGMENT_DIR)/xenix \
$(MAGIC_FRAGMENT_DIR)/xilinx \
MAGIC = $(pkgdatadir)/magic
lib_LTLIBRARIES = libmagic.la
-include_HEADERS = magic.h
+nodist_include_HEADERS = magic.h
bin_PROGRAMS = file
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.247 2016/01/19 15:18:02 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.248 2016/03/31 17:51:12 christos Exp $")
#endif /* lint */
#include "magic.h"
(void)close(fd);
rv = 0;
out:
+ apprentice_unmap(map);
free(dbname);
return rv;
}
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.79 2016/04/26 12:37:34 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.81 2016/06/01 22:21:14 christos Exp $")
#endif
#include <assert.h>
{
size_t ss = CDF_SHORT_SEC_SIZE(h), i, j;
scn->sst_tab = NULL;
- scn->sst_len = cdf_count_chain(ssat, sid, ss);
+ scn->sst_len = cdf_count_chain(ssat, sid, CDF_SEC_SIZE(h));
scn->sst_dirlen = len;
scn->sst_ss = ss;
- if (sst->sst_tab == NULL || scn->sst_len == (size_t)-1)
+ if (scn->sst_len == (size_t)-1)
goto out;
scn->sst_tab = calloc(scn->sst_len, ss);
cdf_secid_t sid = h->h_secid_first_sector_in_short_sat;
ssat->sat_tab = NULL;
- ssat->sat_len = cdf_count_chain(sat, sid, CDF_SEC_SIZE(h));
+ ssat->sat_len = cdf_count_chain(sat, sid, ss);
if (ssat->sat_len == (size_t)-1)
goto out;
if (b > eb)
break;
}
+ if (nr == 0)
+ return -1;
nr--;
*cat = CAST(cdf_catalog_t *,
malloc(sizeof(cdf_catalog_t) + nr * sizeof(*ce)));
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.95 2016/04/19 23:36:36 christos Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.96 2016/04/20 00:00:26 christos Exp $")
#endif
#include "magic.h"
#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif
-#if defined(HAVE_ZLIB_H) && defined(HAVE_LIBZ)
+#if defined(HAVE_ZLIB_H)
#define BUILTIN_DECOMPRESS
#include <zlib.h>
-#define ZLIBSUPPORT
#endif
#ifdef DEBUG
int tty = -1;
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: der.c,v 1.5 2016/04/17 19:44:45 christos Exp $")
+FILE_RCSID("@(#)$File: der.c,v 1.6 2016/04/21 14:26:03 christos Exp $")
#endif
#endif
der_offs(struct magic_set *ms, struct magic *m, size_t nbytes)
{
const uint8_t *b = CAST(const void *, ms->search.s);
- size_t offs = 0, len = ms->search.rm_len ? ms->search.rm_len : nbytes;
+ size_t offs = 0, len = ms->search.s_len ? ms->search.s_len : nbytes;
if (gettag(b, &offs, len) == DER_BAD)
return -1;
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: file.c,v 1.169 2016/03/14 02:30:22 christos Exp $")
+FILE_RCSID("@(#)$File: file.c,v 1.170 2016/03/31 17:51:12 christos Exp $")
#endif /* lint */
#include "magic.h"
if (c == -1) {
(void)fprintf(stderr, "%s: %s\n", progname,
magic_error(magic));
- return 1;
+ e = 1;
+ goto out;
}
- return 0;
+ goto out;
default:
if (magic == NULL)
if ((magic = load(magicfile, flags)) == NULL)
e |= process(magic, argv[optind], wid);
}
+out:
if (magic)
magic_close(magic);
return e;
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.230 2016/04/18 15:10:34 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.233 2016/06/01 22:04:10 christos Exp $")
#endif /* lint */
#include "magic.h"
"Bad DER offset %d nbytes=%zu",
o, nbytes);
}
+ *op = 0;
return 0;
}
break;
switch (type) {
case FILE_DER:
case FILE_SEARCH:
+ if (offset > nbytes)
+ offset = nbytes;
ms->search.s = RCAST(const char *, s) + offset;
ms->search.s_len = nbytes - offset;
ms->search.offset = offset;
if (slen != 0) {
copy = malloc(slen);
if (copy == NULL) {
+ file_regfree(&rx);
file_error(ms, errno,
"can't allocate %" SIZE_T_FORMAT "u bytes",
slen);
--- /dev/null
+Microsoft OOXML
\ No newline at end of file