from ftp.astron.com, this is a bug fix release:

* always leave magic file loaded, don't unload for magic_check, etc.
       * fix default encoding to binary instead of unknown which broke recently
       * handle empty and one byte files, less specially so that
         --mime-encoding does not break completely.
       * fix erroneous non-zero exit code from non-existant file and message
       * add CDF MSI file detection (Guy Helmer)
This commit is contained in:
christos 2013-12-01 19:28:08 +00:00
parent 8370a84a29
commit 8df916c0a5
40 changed files with 1107 additions and 173 deletions

View File

@ -1,3 +1,55 @@
2013-11-19 20:10 Christos Zoulas <christos@zoulas.com>
* always leave magic file loaded, don't unload for magic_check, etc.
* fix default encoding to binary instead of unknown which broke recently
* handle empty and one byte files, less specially so that
--mime-encoding does not break completely.
`
2013-11-06 14:40 Christos Zoulas <christos@zoulas.com>
* fix erroneous non-zero exit code from non-existant file and message
2013-10-29 14:25 Christos Zoulas <christos@zoulas.com>
* add CDF MSI file detection (Guy Helmer)
2013-09-03 11:56 Christos Zoulas <christos@zoulas.com>
* Don't mix errors and regular output if there was an error
* in magic_descriptor() don't close the file and try to restore
its position
2013-05-30 17:25 Christos Zoulas <christos@zoulas.com>
* Don't treat magic as an error if offset was past EOF (Christoph Biedl)
2013-05-28 17:25 Christos Zoulas <christos@zoulas.com>
* Fix spacing issues in softmagic and elf (Jan Kaluza)
2013-05-02 18:00 Christos Zoulas <christos@zoulas.com>
* Fix segmentation fault with multiple magic_load commands.
2013-04-22 11:20 Christos Zoulas <christos@zoulas.com>
* The way "default" was implemented was not very useful
because the "if something was printed at that level"
was not easily controlled by the user, and the format
was bound to a string which is too restrictive. Add
a "clear" for that level keyword and make "default"
void. This way one can do:
>>13 clear x
>>13 lelong 1 foo
>>13 lelong 2 bar
>>13 default x
>>>13 lelong x unknown %x
2013-03-25 13:20 Christos Zoulas <christos@zoulas.com>
* disallow strength setting in "name" entries
2013-03-06 21:24 Christos Zoulas <christos@zoulas.com>
* fix recursive magic separator printing

View File

@ -1,7 +1,8 @@
** README for file(1) Command **
@(#) $File: README,v 1.45 2013/01/11 16:51:01 christos Exp $
@(#) $File: README,v 1.47 2013/06/04 23:15:02 ian Exp $
Mailing List: file@mx.gw.com
Mailing List archives: http://mx.gw.com/pipermail/file/
Bug tracker: http://bugs.gw.com/
E-mail: christos@astron.com
@ -13,11 +14,11 @@ It knows the 'magic number' of several thousands of file types.
This version is the standard "file" command for Linux,
*BSD, and other systems. (See "patchlevel.h" for the exact release number).
You can download the latest version of file from:
You can download the latest version of the original sources for file from:
ftp://ftp.astron.com/pub/file/
A public read-only git repository is available at:
A public read-only git repository of the same sources is available at:
https://github.com/glensc/file
@ -28,7 +29,7 @@ The major feature of 4.x is the refactoring of the code into a library,
and the re-write of the file command in terms of that library. The library
itself, libmagic can be used by 3rd party programs that wish to identify
file types without having to fork() and exec() file. The prime contributor
for 4.0 was M\xe5ns Rullg\xe5rd.
for 4.0 was Mans Rullgard.
UNIX is a trademark of UNIX System Laboratories.

View File

@ -9,8 +9,9 @@ listed in the BUGS section of the man page had been fixed!)
It would be nice to simplify file considerably. For example,
reimplement the apprentice and non-pattern magic methods in Python,
and compile the magic patterns to a giant regex (or something similar)
so that only a small amount of C is needed (because fast execution is
typically only required for soft magic, not the more detailed
information given by hard-wired routines). In this regard, note that
hplip, which is BSD-licensed, has a magic reimplementation in Python.
and compile the magic patterns to a giant regex (or something similar;
maybe using Ragel (http://www.complang.org/ragel/)) so that only a
small amount of C is needed (because fast execution is typically only
required for soft magic, not the more detailed information given by
hard-wired routines). In this regard, note that hplip, which is
BSD-licensed, has a magic reimplementation in Python.

View File

@ -2,6 +2,6 @@
#------------------------------------------------------------------------------
# Localstuff: file(1) magic for locally observed files
#
# $File: Localstuff,v 1.5 2007/01/12 17:38:27 christos Exp $
# $File: Localstuff,v 1.4 2003/03/23 04:17:27 christos Exp $
# Add any locally observed files here. Remember:
# text if readable, executable if runnable binary, data if unreadable.

View File

@ -0,0 +1,100 @@
#------------------------------------------------------------
# $File: android,v 1.3 2013/11/08 01:24:22 christos Exp $
# Various android related magic entries
#------------------------------------------------------------
# Dalvik .dex format. http://retrodev.com/android/dexformat.html
# From <mkf@google.com> "Mike Fleming"
# Fixed to avoid regexec 17 errors on some dex files
# From <diff@lookout.com> "Tim Strazzere"
0 string dex\n
>0 regex dex\n[0-9]{2}\0 Dalvik dex file
>4 string >000 version %s
0 string dey\n
>0 regex dey\n[0-9]{2}\0 Dalvik dex file (optimized for host)
>4 string >000 version %s
# http://android.stackexchange.com/questions/23357/\
# is-there-a-way-to-look-inside-and-modify-an-adb-backup-created-file/\
# 23608#23608
0 string ANDROID\040BACKUP\n Android Backup
>15 string 1\n \b, version 1
>17 string 0\n \b, uncompressed
>17 string 1\n \b, compressed
>19 string none\n \b, unencrypted
>19 string AES-256\n \b, encrypted AES-256
# Android bootimg format
# From https://android.googlesource.com/\
# platform/system/core/+/master/mkbootimg/bootimg.h
0 string ANDROID! Android bootimg
>8 lelong >0 \b, kernel
>>12 lelong >0 \b (0x%x)
>16 lelong >0 \b, ramdisk
>>20 lelong >0 \b (0x%x)
>24 lelong >0 \b, second stage
>>28 lelong >0 \b (0x%x)
>36 lelong >0 \b, page size: %d
>38 string >0 \b, name: %s
>64 string >0 \b, cmdline (%s)
# Dalvik .dex format. http://retrodev.com/android/dexformat.html
# From <mkf@google.com> "Mike Fleming"
# Fixed to avoid regexec 17 errors on some dex files
# From <diff@lookout.com> "Tim Strazzere"
0 string dex\n
>0 regex dex\n[0-9]{2}\0 Dalvik dex file
>4 string >000 version %s
0 string dey\n
>0 regex dey\n[0-9]{2}\0 Dalvik dex file (optimized for host)
>4 string >000 version %s
# http://android.stackexchange.com/questions/23357/\
# is-there-a-way-to-look-inside-and-modify-an-adb-backup-created-file/\
# 23608#23608
0 string ANDROID\040BACKUP\n Android Backup
>15 string 1\n \b, version 1
>17 string 0\n \b, uncompressed
>17 string 1\n \b, compressed
>19 string none\n \b, unencrypted
>19 string AES-256\n \b, encrypted AES-256
# Android bootimg format
# From https://android.googlesource.com/\
# platform/system/core/+/master/mkbootimg/bootimg.h
0 string ANDROID! Android bootimg
>8 lelong >0 \b, kernel
>>12 lelong >0 \b (0x%x)
>16 lelong >0 \b, ramdisk
>>20 lelong >0 \b (0x%x)
>24 lelong >0 \b, second stage
>>28 lelong >0 \b (0x%x)
>36 lelong >0 \b, page size: %d
>38 string >0 \b, name: %s
>64 string >0 \b, cmdline (%s)
# Android Backup archive
# From: Ariel Shkedi
# File extension: .ab
# No mime-type defined
# URL: https://github.com/android/platform_frameworks_base/blob/\
# 0bacfd2ba68d21a68a3df345b830bc2a1e515b5a/services/java/com/\
# android/server/BackupManagerService.java#L2367
# After the header comes a tar file
# If compressed, the entire tar file is compressed with JAVA deflate
#
# Include the version number hardcoded with the magic string to avoid
# false positives
0 string/b ANDROID\ BACKUP\n1\n Android Backup
>17 string 0\n \b, Not-Compressed
>17 string 1\n \b, Compressed
# any string as long as it's not the word none (which is matched below)
>>19 regex/1 \^([^n\n]|n[^o]|no[^n]|non[^e]|none.+).* \b, Encrypted (%s)
>>19 string none\n \b, Not-Encrypted
# Commented out because they don't seem useful to print
# (but they are part of the header - the tar file comes after them):
#>>>&1 regex/1 .* \b, Password salt: %s
#>>>>&1 regex/1 .* \b, Master salt: %s
#>>>>>&1 regex/1 .* \b, PBKDF2 rounds: %s
#>>>>>>&1 regex/1 .* \b, IV: %s
#>>>>>>>&1 regex/1 .* \b, Key: %s

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: animation,v 1.48 2013/03/09 22:36:00 christos Exp $
# $File: animation,v 1.49 2013/08/15 13:15:11 christos Exp $
# animation: file(1) magic for animation/movie formats
#
# animation formats
@ -802,7 +802,7 @@
!:mime video/mp4v-es
0 belong 0x000001B3
!:mime video/mpv
0 belong&0xFF5FFF1F 0x47400010
0 belong&0xFF5FFF10 0x47400010
!:mime video/mp2t
0 belong 0x00000001
>4 byte&0x1F 0x07

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: audio,v 1.66 2013/02/06 14:18:52 christos Exp $
# $File: audio,v 1.67 2013/08/14 09:01:45 christos Exp $
# audio: file(1) magic for sound formats (see also "iff")
#
# Jan Nicolai Langfeldt (janl@ifi.uio.no), Dan Quinlan (quinlan@yggdrasil.com),
@ -637,3 +637,56 @@
# URL: http://wiki.multimedia.cx/index.php?title=WavPack
# From: Mike Melanson <mike@multimedia.cx>
0 string wvpk WavPack Lossless Audio
# From Fábio R. Schmidlin <frs@pop.com.br>
# VGM music file
0 string Vgm\
>9 ubyte >0 VGM Video Game Music dump v
>>9 ubyte/16 >0 \b%d
>>9 ubyte&0x0F x \b%d
>>8 ubyte/16 x \b.%d
>>8 ubyte&0x0F >0 \b%d
#Get soundchips
>>8 ubyte x \b, soundchip(s)=
>>0x0C ulelong >0 SN76489,
>>0x10 ulelong >0 YM2413,
>>0x2C ulelong >0 YM2612,
>>0x30 ulelong >0 YM2151,
>>0x38 ulelong >0 Sega PCM,
>>0x34 ulelong >0xC
>>>0x40 ulelong >0 RF5C68,
>>0x34 ulelong >0x10
>>>0x44 ulelong >0 YM2203,
>>0x34 ulelong >0x14
>>>0x48 ulelong >0 YM2608,
>>0x34 ulelong >0x18
>>>0x4C lelong >0 YM2610,
>>>0x4C lelong <0 YM2610B,
>>0x34 ulelong >0x1C
>>>0x50 ulelong >0 YM3812,
>>0x34 ulelong >0x20
>>>0x54 ulelong >0 YM3526,
>>0x34 ulelong >0x24
>>>0x58 ulelong >0 Y8950,
>>0x34 ulelong >0x28
>>>0x5C ulelong >0 YMF262,
>>0x34 ulelong >0x2C
>>>0x60 ulelong >0 YMF278B,
>>0x34 ulelong >0x30
>>>0x64 ulelong >0 YMF271,
>>0x34 ulelong >0x34
>>>0x68 ulelong >0 YMZ280B,
>>0x34 ulelong >0x38
>>>0x6C ulelong >0 RF5C164,
>>0x34 ulelong >0x3C
>>>0x70 ulelong >0 PWM,
>>0x34 ulelong >0x40
>>>0x74 ulelong >0
>>>>0x78 ubyte 0x00 AY-3-8910,
>>>>0x78 ubyte 0x01 AY-3-8912,
>>>>0x78 ubyte 0x02 AY-3-8913,
>>>>0x78 ubyte 0x03 AY-3-8930,
>>>>0x78 ubyte 0x10 YM2149,
>>>>0x78 ubyte 0x11 YM3439,

View File

@ -1,5 +1,5 @@
#------------------------------------------------------------------------------
# $File: c-lang,v 1.17 2012/04/28 21:20:26 christos Exp $
# $File: c-lang,v 1.18 2013/08/14 13:06:43 christos Exp $
# c-lang: file(1) magic for C and related languages programs
#
@ -12,30 +12,30 @@
# C
0 regex \^#include C source text
!:mime text/x-c
0 regex \^char C source text
0 regex \^char[\ \t\n]+ C source text
!:mime text/x-c
0 regex \^double C source text
0 regex \^double[\ \t\n]+ C source text
!:mime text/x-c
0 regex \^extern C source text
0 regex \^extern[\ \t\n]+ C source text
!:mime text/x-c
0 regex \^float C source text
0 regex \^float[\ \t\n]+ C source text
!:mime text/x-c
0 regex \^struct C source text
0 regex \^struct[\ \t\n]+ C source text
!:mime text/x-c
0 regex \^union C source text
0 regex \^union[\ \t\n]+ C source text
!:mime text/x-c
0 search/8192 main( C source text
!:mime text/x-c
# C++
# The strength of these rules is increased so they beat the C rules above
0 regex \^template C++ source text
0 regex \^template[\ \t\n]+ C++ source text
!:strength + 5
!:mime text/x-c++
0 regex \^virtual C++ source text
0 regex \^virtual[\ \t\n]+ C++ source text
!:strength + 5
!:mime text/x-c++
0 regex \^class C++ source text
0 regex \^class[\ \t\n]+ C++ source text
!:strength + 5
!:mime text/x-c++
0 regex \^public: C++ source text

View File

@ -1,16 +1,9 @@
#------------------------------------------------------------------------------
# $File: cad,v 1.11 2011/12/08 12:12:46 rrt Exp $
# $File: cad,v 1.12 2013/07/04 15:24:37 christos Exp $
# autocad: file(1) magic for cad files
#
# AutoCAD DWG versions R13/R14 (www.autodesk.com)
# Written December 01, 2003 by Lester Hightower
# Based on the DWG File Format Specifications at http://www.opendwg.org/
0 string \101\103\061\060\061 AutoCAD
>5 string \062\000\000\000\000 DWG ver. R13
>5 string \064\000\000\000\000 DWG ver. R14
# Microstation DGN/CIT Files (www.bentley.com)
# Last updated July 29, 2005 by Lester Hightower
# DGN is the default file extension of Microstation/Intergraph CAD files.
@ -49,19 +42,62 @@
>4 string \030\000\000 CITFile
>4 string \030\000\003 CITFile
# AutoCAD
# Merge of the different contributions and updates from http://en.wikipedia.org/wiki/Dwg
# and http://www.iana.org/assignments/media-types/image/vnd.dwg
0 string MC0.0 DWG AutoDesk AutoCAD Release 1.0
!:mime image/vnd.dwg
0 string AC1.2 DWG AutoDesk AutoCAD Release 1.2
!:mime image/vnd.dwg
0 string AC1.3 DWG AutoDesk AutoCAD Release 1.3
!:mime image/vnd.dwg
0 string AC1.40 DWG AutoDesk AutoCAD Release 1.40
!:mime image/vnd.dwg
0 string AC1.50 DWG AutoDesk AutoCAD Release 2.05
!:mime image/vnd.dwg
0 string AC2.10 DWG AutoDesk AutoCAD Release 2.10
!:mime image/vnd.dwg
0 string AC2.21 DWG AutoDesk AutoCAD Release 2.21
!:mime image/vnd.dwg
0 string AC2.22 DWG AutoDesk AutoCAD Release 2.22
!:mime image/vnd.dwg
0 string AC1001 DWG AutoDesk AutoCAD Release 2.22
!:mime image/vnd.dwg
0 string AC1002 DWG AutoDesk AutoCAD Release 2.50
!:mime image/vnd.dwg
0 string AC1003 DWG AutoDesk AutoCAD Release 2.60
!:mime image/vnd.dwg
0 string AC1004 DWG AutoDesk AutoCAD Release 9
!:mime image/vnd.dwg
0 string AC1006 DWG AutoDesk AutoCAD Release 10
!:mime image/vnd.dwg
0 string AC1009 DWG AutoDesk AutoCAD Release 11/12
!:mime image/vnd.dwg
# AutoCAD DWG versions R13/R14 (www.autodesk.com)
# Written December 01, 2003 by Lester Hightower
# Based on the DWG File Format Specifications at http://www.opendwg.org/
# AutoCad, from Nahuel Greco
# AutoCAD DWG versions R12/R13/R14 (www.autodesk.com)
0 string AC1012 DWG AutoDesk AutoCad (release 12)
0 string AC1013 DWG AutoDesk AutoCad (release 13)
0 string AC1014 DWG AutoDesk AutoCad (release 14)
0 string AC1012 DWG AutoDesk AutoCAD Release 13
!:mime image/vnd.dwg
0 string AC1014 DWG AutoDesk AutoCAD Release 14
!:mime image/vnd.dwg
0 string AC1015 DWG AutoDesk AutoCAD 2000/2002
!:mime image/vnd.dwg
# A new version of AutoCAD DWG
# Sergey Zaykov (mail_of_sergey@mail.ru, sergey_zaikov@rambler.ru,
# ICQ 358572321)
# From various sources like:
# http://autodesk.blogs.com/between_the_lines/autocad-release-history.html
0 string AC1018 DWG AutoDesk AutoCAD 2004/2005/2006
0 string AC1021 DWG AutoDesk AutoCAD 2007/2008/2009
0 string AC1024 DWG AutoDesk AutoCAD 2010/2011
0 string AC1018 DWG AutoDesk AutoCAD 2004/2005/2006
!:mime image/vnd.dwg
0 string AC1021 DWG AutoDesk AutoCAD 2007/2008/2009
!:mime image/vnd.dwg
0 string AC1024 DWG AutoDesk AutoCAD 2010/2011/2012
!:mime image/vnd.dwg
0 string AC1027 DWG AutoDesk AutoCAD 2013/2014
!:mime image/vnd.dwg
# KOMPAS 2D drawing from ASCON
# This is KOMPAS 2D drawing or fragment of drawing but is not detailed nor
@ -110,9 +146,6 @@
0 beshort 0x0809 Bentley/Intergraph MicroStation
>0x02 byte 0xfe
>>0x04 beshort 0x1800 CIT raster CAD
0 string AC1012 AutoDesk AutoCAD R13
0 string AC1014 AutoDesk AutoCAD R14
0 string AC1015 AutoDesk AutoCAD R2000
# 3DS (3d Studio files) Conflicts with diff output 0x3d '='
#16 beshort 0x3d3d image/x-3ds

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: commands,v 1.45 2013/02/06 14:18:52 christos Exp $
# $File: commands,v 1.46 2013/03/25 14:06:55 christos Exp $
# commands: file(1) magic for various shells and interpreters
#
#0 string/w : shell archive or script for antique kernel text
@ -49,7 +49,7 @@
!:mime text/x-awk
0 string/wt #!\ /usr/bin/awk awk script text executable
!:mime text/x-awk
0 regex =^\\s*BEGIN\\s*[{] awk script text
0 regex =^\\s{0,100}BEGIN\\s{0,100}[{] awk script text
# AT&T Bell Labs' Plan 9 shell
0 string/wt #!\ /bin/rc Plan 9 rc shell script text executable

View File

@ -1,5 +1,5 @@
#------------------------------------------------------------------------------
# $File: compress,v 1.49 2011/12/07 22:04:27 christos Exp $
# $File: compress,v 1.51 2013/11/19 20:38:57 christos Exp $
# compress: file(1) magic for pure-compression formats (no archives)
#
# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
@ -191,10 +191,13 @@
# Type: LZMA
0 lelong&0xffffff =0x5d
>12 leshort =0xff LZMA compressed data,
!:mime application/x-lzma
>12 leshort 0xff LZMA compressed data,
>>5 lequad =0xffffffffffffffff streamed
>>5 lequad !0xffffffffffffffff non-streamed, size %lld
>12 leshort 0 LZMA compressed data,
>>5 lequad =0xffffffffffffffff streamed
>>5 lequad !0xffffffffffffffff non-streamed, size %lld
!:mime application/x-lzma
# http://tukaani.org/xz/xz-file-format.txt
0 ustring \xFD7zXZ\x00 XZ compressed data
@ -229,3 +232,9 @@
>6 byte >-1 %i)
>7 long >0 , original size: %i bytes
>15 long >30 , block size: %i bytes
# Valve Pack (VPK) files
0 lelong 0x55aa1234 Valve Pak file
>0x4 lelong x \b, version %u
>0x8 lelong x \b, %u entries

23
external/bsd/file/dist/magic/magdir/ctf vendored Normal file
View File

@ -0,0 +1,23 @@
#--------------------------------------------------------------
# ctf: file(1) magic for CTF (Common Trace Format) trace files
#
# Specs. available here: <http://www.efficios.com/ctf>
#--------------------------------------------------------------
# CTF trace data
0 lelong 0xc1fc1fc1 Common Trace Format (CTF) trace data (LE)
0 belong 0xc1fc1fc1 Common Trace Format (CTF) trace data (BE)
# CTF metadata (packetized)
0 lelong 0x75d11d57 Common Trace Format (CTF) packetized metadata (LE)
>35 byte x \b, v%d
>36 byte x \b.%d
0 belong 0x75d11d57 Common Trace Format (CTF) packetized metadata (BE)
>35 byte x \b, v%d
>36 byte x \b.%d
# CTF metadata (plain text)
0 string /*\x20CTF\x20 Common Trace Format (CTF) plain text metadata
!:strength + 5 # this is to make sure we beat C
>&0 regex [0-9]+\.[0-9]+ \b, v%s

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: database,v 1.33 2013/03/09 22:36:00 christos Exp $
# $File: database,v 1.35 2013/11/20 00:00:14 christos Exp $
# database: file(1) magic for various databases
#
# extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk)
@ -84,8 +84,8 @@
#
#
# Round Robin Database Tool by Tobias Oetiker <oetiker@ee.ethz.ch>
0 string RRD RRDTool DB
>4 string x version %s
0 string/b RRD\0 RRDTool DB
>4 string/b x version %s
#----------------------------------------------------------------------
# ROOT: file(1) magic for ROOT databases
#
@ -303,7 +303,10 @@
>>>>>>>8 ubelong 0
# skip MM*DD*.bin by test for for reserved NULL byte
>>>>>>>>508 ubelong 0
>>>>>>>>>0 use xbase-memo-print
# real memo files should contain text here
>>>>>>>>>520 ubelong >0x20202019
>>>>>>>>>>520 ubelong <0xFEFEFEFF
>>>>>>>>>>>0 use xbase-memo-print
# garbage PCX , ZIP , JAR , XPI
>>>>>>>8 default x

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: fsav,v 1.11 2009/09/19 16:28:09 christos Exp $
# $File: fsav,v 1.13 2013/03/25 17:18:47 christos Exp $
# fsav: file(1) magic for datafellows fsav virus definition files
# Anthon van der Neut (anthon@mnt.org)
@ -61,3 +61,6 @@
# Type: Grisoft AVG AntiVirus
# From: David Newgas <david@newgas.net>
0 string AVG7_ANTIVIRUS_VAULT_FILE AVG 7 Antivirus vault file data
0 string X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR
>33 string -STANDARD-ANTIVIRUS-TEST-FILE!$H+H* EICAR virus test files

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: ibm6000,v 1.11 2013/01/08 20:13:01 christos Exp $
# $File: ibm6000,v 1.12 2013/09/16 15:12:42 christos Exp $
# ibm6000: file(1) magic for RS/6000 and the RT PC.
#
0 beshort 0x01df executable (RISC System/6000 V3.1) or obj module
@ -20,9 +20,12 @@
0 beshort 0x01f7 64-bit XCOFF executable or object module
>20 belong 0 not stripped
4 belong &0x0feeddb0 AIX core file
>1 byte &0x01 fulldump
>7 byte &0x01 32-bit
>>0x6e0 string >\0 \b, %s
>7 byte &0x02 64-bit
>>0x524 string >\0 \b, %s
# GRR: this test is still too general as it catches also many FATs of DOS filesystems
4 belong &0x0feeddb0
# real core dump could not be 32-bit and 64-bit together
>7 byte&0x03 !3 AIX core file
>>1 byte &0x01 fulldump
>>7 byte &0x01 32-bit
>>>0x6e0 string >\0 \b, %s
>>7 byte &0x02 64-bit
>>>0x524 string >\0 \b, %s

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: images,v 1.81 2013/03/09 22:36:00 christos Exp $
# $File: images,v 1.86 2013/11/19 23:56:04 christos Exp $
# images: file(1) magic for image formats (see also "iff", and "c-lang" for
# XPM bitmaps)
#
@ -45,7 +45,7 @@
>>3 regex =\ [0-9]+ \b%s
!:strength + 45
!:mime image/x-portable-greymap
0 search/1 P3 Netpbm PPM image text
0 search/1 P3
>3 regex =[0-9]*\ [0-9]* Netpbm PPM image text
>3 regex =[0-9]+\ \b, size = %sx
>>3 regex =\ [0-9]+ \b%s
@ -256,6 +256,8 @@
# at offset 8 starts imagedata followed by "RGB " marker
# PC bitmaps (OS/2, Windows BMP files) (Greg Roelofs, newt@uchicago.edu)
# http://en.wikipedia.org/wiki/BMP_file_format#DIB_header_.\
# 28bitmap_information_header.29
0 string BM
>14 leshort 12 PC bitmap, OS/2 1.x format
!:mime image/x-ms-bmp
@ -270,6 +272,16 @@
>>18 lelong x \b, %d x
>>22 lelong x %d x
>>28 leshort x %d
>14 leshort 124 PC bitmap, Windows 98/2000 and newer format
!:mime image/x-ms-bmp
>>18 lelong x \b, %d x
>>22 lelong x %d x
>>28 leshort x %d
>14 leshort 108 PC bitmap, Windows 95/NT4 and newer format
!:mime image/x-ms-bmp
>>18 lelong x \b, %d x
>>22 lelong x %d x
>>28 leshort x %d
>14 leshort 128 PC bitmap, Windows NT/2000 format
!:mime image/x-ms-bmp
>>18 lelong x \b, %d x
@ -734,6 +746,15 @@
!:mime application/x-hdf
0 string \211HDF\r\n\032\n Hierarchical Data Format (version 5) data
!:mime application/x-hdf
512 string \211HDF\r\n\032\n Hierarchical Data Format (version 5) with 512 bytes user block
!:mime application/x-hdf
1024 string \211HDF\r\n\032\n Hierarchical Data Format (version 5) with 1k user block
!:mime application/x-hdf
2048 string \211HDF\r\n\032\n Hierarchical Data Format (version 5) with 2k user block
!:mime application/x-hdf
4096 string \211HDF\r\n\032\n Hierarchical Data Format (version 5) with 4k user block
!:mime application/x-hdf
# From: Tobias Burnus <burnus@net-b.de>
# Xara (for a while: Corel Xara) is a graphic package, see
@ -769,6 +790,34 @@
# From Tano M Fotang <mfotang@quanteq.com>
0 string \xff\xa0\xff\xa8\x00 Wavelet Scalar Quantization image data
# Type: PCO B16 image files
# URL: http://www.pco.de/fileadmin/user_upload/db/download/MA_CWDCOPIE_0412b.pdf
# From: Florian Philipp <florian.philipp@binarywings.net>
# Extension: .b16
# Description: Pixel image format produced by PCO Camware, typically used
# together with PCO cameras.
# Note: Different versions exist for e.g. 8 bit and 16 bit images.
# Documentation is incomplete.
0 string/b PCO- PCO B16 image data
>12 lelong x \b, %dx
>16 lelong x \b%d
>20 lelong 0 \b, short header
>20 lelong -1 \b, extended header
>>24 lelong 0 \b, grayscale
>>>36 lelong 0 linear LUT
>>>36 lelong 1 logarithmic LUT
>>>28 lelong x [%d
>>>32 lelong x \b,%d]
>>24 lelong 1 \b, color
>>>64 lelong 0 linear LUT
>>>64 lelong 1 logarithmic LUT
>>>40 lelong x r[%d
>>>44 lelong x \b,%d]
>>>48 lelong x g[%d
>>>52 lelong x \b,%d]
>>>56 lelong x b[%d
>>>60 lelong x \b,%d]
# Polar Monitor Bitmap (.pmb) used as logo for Polar Electro watches
# From: Markus Heidelberg <markus.heidelberg at web.de>
0 string/t [BitmapInfo2] Polar Monitor Bitmap text
@ -838,3 +887,8 @@
# Not really an image.
# From: "Tano M. Fotang" <mfotang@quanteq.com>
0 string \x46\x4d\x52\x00 ISO/IEC 19794-2 Format Minutiae Record (FMR)
# WEBP https://developers.google.com/speed/webp/docs/riff_container
0 string RIFF
>8 string WEBP Web/P image data
>>4 lelong x \b, %d bytes

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------
# $File: java,v 1.14 2013/02/08 16:54:45 christos Exp $
# $File: java,v 1.16 2013/09/24 20:22:03 christos Exp $
# Java ByteCode and Mach-O binaries (e.g., Mac OS X) use the
# same magic number, 0xcafebabe, so they are both handled
# in the entry called "cafebabe".
@ -15,25 +15,6 @@
0 belong 0xcececece Java JCE KeyStore
!:mime application/x-java-jce-keystore
# Dalvik .dex format. http://retrodev.com/android/dexformat.html
# From <mkf@google.com> "Mike Fleming"
0 string dex\n
>0 regex dex\n[0-9][0-9][0-9]\0 Dalvik dex file
>4 string >000 version %s
0 string dey\n
>0 regex dey\n[0-9][0-9][0-9]\0 Dalvik dex file (optimized for host)
>4 string >000 version %s
# Java source
0 regex ^import.*;$ Java source
!:mime text/x-java
# http://android.stackexchange.com/questions/23357/\
# is-there-a-way-to-look-inside-and-modify-an-adb-backup-created-file/\
# 23608#23608
0 string ANDROID\040BACKUP\n Android Backup
>15 string 1\n \b, version 1
>17 string 0\n \b, uncompressed
>17 string 1\n \b, compressed
>19 string none\n \b, unencrypted
>19 string AES-256\n \b, encrypted AES-256

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: linux,v 1.47 2013/02/06 14:18:52 christos Exp $
# $File: linux,v 1.52 2013/11/19 23:18:15 christos Exp $
# linux: file(1) magic for Linux files
#
# Values for Linux/i386 binaries, from Daniel Quinlan <quinlan@yggdrasil.com>
@ -98,12 +98,13 @@
# All known start with: b8 c0 07 8e d8 b8 00 90 8e c0 b9 00 01 29 f6 29
# Linux kernel boot images (i386 arch) (Wolfram Kleff)
514 string HdrS Linux kernel
!:strength + 5
!:strength + 55
>510 leshort 0xAA55 x86 boot executable
>>518 leshort >0x1ff
>>>529 byte 0 zImage,
>>>529 byte 1 bzImage,
>>>(526.s+0x200) string >\0 version %s,
>>>526 lelong >0
>>>>(526.s+0x200) string >\0 version %s,
>>498 leshort 1 RO-rootFS,
>>498 leshort 0 RW-rootFS,
>>508 leshort >0 root_dev 0x%X,
@ -344,3 +345,50 @@
#>2 regex \(name\ [^)]*\) %s
>20 search/256 (name (name
>>&1 string x %s...)
# Systemd journald files
# See http://www.freedesktop.org/wiki/Software/systemd/journal-files/.
# From: Zbigniew Jedrzejewski-Szmek <zbyszek@in.waw.pl>
# check magic
0 string LPKSHHRH
# check that state is one of known values
>16 ubyte&252 0
# check that each half of three unique id128s is non-zero
>>24 ubequad >0
>>>32 ubequad >0
>>>>40 ubequad >0
>>>>>48 ubequad >0
>>>>>>56 ubequad >0
>>>>>>>64 ubequad >0 Journal file
!:mime application/octet-stream
# provide more info
>>>>>>>>184 leqdate 0 empty
>>>>>>>>16 ubyte 0 \b, offline
>>>>>>>>16 ubyte 1 \b, online
>>>>>>>>16 ubyte 2 \b, archived
>>>>>>>>8 ulelong&1 1 \b, sealed
>>>>>>>>12 ulelong&1 1 \b, compressed
# BCache backing and cache devices
# From: Gabriel de Perthuis <g2p.code@gmail.com>
0x1008 lequad 8
>0x1018 string \xc6\x85\x73\xf6\x4e\x1a\x45\xca\x82\x65\xf5\x7f\x48\xba\x6d\x81 BCache
>>0x1010 ulequad 0 cache device
>>0x1010 ulequad 1 backing device
>>0x1010 ulequad 3 cache device
>>0x1010 ulequad 4 backing device
>>0x1048 string >0 \b, label "%.32s"
>>0x1028 ubelong x \b, uuid %08x
>>0x102c ubeshort x \b-%04x
>>0x102e ubeshort x \b-%04x
>>0x1030 ubeshort x \b-%04x
>>0x1032 ubelong x \b-%08x
>>0x1036 ubeshort x \b%04x
>>0x1038 ubelong x \b, set uuid %08x
>>0x103c ubeshort x \b-%04x
>>0x103e ubeshort x \b-%04x
>>0x1040 ubeshort x \b-%04x
>>0x1042 ubelong x \b-%08x
>>0x1046 ubeshort x \b%04x

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: macintosh,v 1.22 2011/05/17 17:40:31 rrt Exp $
# $File: macintosh,v 1.23 2013/11/19 18:47:58 christos Exp $
# macintosh description
#
# BinHex is the Macintosh ASCII-encoded file format (see also "apple")
@ -263,6 +263,9 @@
0 string $FL2 SPSS System File
>24 string x %s
0 string $FL3 SPSS System File
>24 string x %s
# Macintosh filesystem data
# From "Tom N Harris" <telliamed@mac.com>
# Fixed HFS+ and Partition map magic: Ethan Benson <erbenson@alaska.net>

View File

@ -1,35 +1,41 @@
#------------------------------------------------------------------------------
# $File: msooxml,v 1.2 2013/01/25 23:04:37 christos Exp $
# $File: msooxml,v 1.3 2013/09/12 16:08:07 christos Exp $
# msooxml: file(1) magic for Microsoft Office XML
# From: Ralf Brown <ralf.brown@gmail.com>
# .docx, .pptx, and .xlsx are XML plus other files inside a ZIP
# archive. The first member file is normally "[Content_Types].xml".
# but some libreoffice generated files put this later. Perhaps skip
# the "[Content_Types].xml" test?
# Since MSOOXML doesn't have anything like the uncompressed "mimetype"
# file of ePub or OpenDocument, we'll have to scan for a filename
# which can distinguish between the three types
# start by checking for ZIP local file header signature
0 string PK\003\004
# make sure the first file is correct
>0x1E string [Content_Types].xml
# skip to the second local file header
# since some documents include a 520-byte extra field following the file
# header, we need to scan for the next header
>>(18.l+49) search/2000 PK\003\004
# now skip to the *third* local file header; again, we need to scan due to a
# 520-byte extra field following the file header
>>>&26 search/1000 PK\003\004
# and check the subdirectory name to determine which type of OOXML
# file we have
# Correct the mimetype with the registered ones:
# http://technet.microsoft.com/en-us/library/cc179224.aspx
>>>>&26 string word/ Microsoft Word 2007+
!:mime application/vnd.openxmlformats-officedocument.wordprocessingml.document
>>>>&26 string ppt/ Microsoft PowerPoint 2007+
!:mime application/vnd.openxmlformats-officedocument.presentationml.presentation
>>>>&26 string xl/ Microsoft Excel 2007+
!:mime application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
>>>>&26 default x Microsoft OOXML
0 string PK\003\004
!:strength +10
# make sure the first file is correct
>0x1E string [Content_Types].xml
>>0 use msooxml
>0xE84 string [Content_Types].xml
>>0 use msooxml
0 name msooxml
# skip to the second local file header
# since some documents include a 520-byte extra field following the file
# header, we need to scan for the next header
>(18.l+49) search/2000 PK\003\004
# now skip to the *third* local file header; again, we need to scan due to a
# 520-byte extra field following the file header
>>&26 search/1000 PK\003\004
# and check the subdirectory name to determine which type of OOXML
# file we have. Correct the mimetype with the registered ones:
# http://technet.microsoft.com/en-us/library/cc179224.aspx
>>>&26 string word/ Microsoft Word 2007+
!:mime application/vnd.openxmlformats-officedocument.wordprocessingml.document
>>>&26 string ppt/ Microsoft PowerPoint 2007+
!:mime application/vnd.openxmlformats-officedocument.presentationml.presentation
>>>&26 string xl/ Microsoft Excel 2007+
!:mime application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
>>>&26 default x Microsoft OOXML

255
external/bsd/file/dist/magic/magdir/msx vendored Normal file
View File

@ -0,0 +1,255 @@
#------------------------------------------------------------------------------
# msx: file(1) magic for the MSX Home Computer
# v1.1
# Fábio R. Schmidlin <sd-snatcher@users.sourceforge.net>
############## MSX Music file formats ##############
# Gigamix MGSDRV music file
0 string MGS MSX Gigamix MGSDRV3 music file,
>6 ubeshort 0x0D0A
>>3 byte x \bv%c
>>4 byte x \b.%c
>>5 byte x \b%c
>>8 string >\0 \b, title: %s
1 string mgs2\ MSX Gigamix MGSDRV2 music file
>6 uleshort 0x80
>>0x2E uleshort 0
>>>0x30 string >\0 \b, title: %s
# KSS music file
0 string KSCC KSS music file v1.03
>0xE byte 0
>>0xF byte&0x02 0 \b, soundchips: AY-3-8910, SCC(+)
>>0xF byte&0x02 2 \b, soundchip(s): SN76489
>>>0xF byte&0x04 4 stereo
>>0xF byte&0x01 1 \b, YM2413
>>0xF byte&0x08 8 \b, Y8950
0 string KSSX KSS music file v1.20
>0xE byte&0xEF 0
>>0xF byte&0x40 0x00 \b, 60Hz
>>0xF byte&0x40 0x40 \b, 50Hz
>>0xF byte&0x02 0 \b, soundchips: AY-3-8910, SCC(+)
>>0xF byte&0x02 0x02 \b, soundchips: SN76489
>>>0xF byte&0x04 0x04 stereo
>>0xF byte&0x01 0x01 \b,
>>>0xF byte&0x18 0x00 \bYM2413
>>>0xF byte&0x18 0x08 \bYM2413, Y8950
>>>0xF byte&0x18 0x18 \bYM2413+Y8950 pseudostereo
>>0xF byte&0x18 0x10 \b, Majyutsushi DAC
# Moonblaster for Moonsound
0 string MBMS
>4 byte 0x10 MSX Moonblaster for MoonSound music
# Music Player K-kaz
0 string MPK MSX Music Player K-kaz song
>6 ubeshort 0x0D0A
>>3 byte x v%c
>>4 byte x \b.%c
>>5 byte x \b%c
# I don't know why these don't work
#0 search/0xFFFF \r\n.FM9
#>0 search/0xFFFF \r\n#FORMAT MSX Music Player K-kaz source MML file
#0 search/0xFFFF \r\nFM1\ \=
#>0 search/0xFFFF \r\nPSG1\=
#>>0 search/0xFFFF \r\nSCC1\= MSX MuSiCa MML source file
# OPX Music file
0x35 beshort 0x0d0a
>0x7B beshort 0x0d0a
>>0x7D byte 0x1a
>>>0x87 uleshort 0 MSX OPX Music file
>>>>0x86 byte 0 v1.5
>>>>>0 string >\32 \b, title: %s
>>>>0x86 byte 1 v2.4
>>>>>0 string >\32 \b, title: %s
# SCMD music file
0x8B string SCMD
>0xCE uleshort 0 MSX SCMD Music file
#>>-2 uleshort 0x6a71 ; The file must end with this value. How to code this here?
>>0x8F string >\0 \b, title: %s
0 search/0xFFFF \r\n@title
>&0 search/0xFFFF \r\n@m=[ MSX SCMD source MML file
############## MSX image file formats ##############
# MSX raw VRAM dump
0 ubyte 0xFE
>1 uleshort 0
>>5 uleshort 0
>>>3 uleshort 0x37FF MSX SC2/GRP raw image
>>>3 uleshort 0x6A00 MSX Graph Saurus SR5 raw image
>>>3 uleshort >0x769E
>>>>3 uleshort <0x8000 MSX GE5/GE6 raw image
>>>>>3 uleshort 0x7FFF \b, with sprite patterns
>>>3 uleshort 0xD3FF MSX screen 7-12 raw image
>>>3 uleshort 0xD400 MSX Graph Saurus SR7/SR8/SRS raw image
# Graph Saurus compressed images
0 ubyte 0xFD
>1 uleshort 0
>>5 uleshort 0
>>>3 uleshort >0x013D MSX Graph Saurus compressed image
# Maki-chan Graphic format
0 string 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 PIC\x1A
>4 lelong 0 Japanese PIC image file
# MSX G9B image file
0 string G9B
>1 uleshort 11
>>3 uleshort >10
>>>5 ubyte >0 MSX G9B image, depth=%d
>>>>8 uleshort x \b, %dx
>>>>10 uleshort x \b%d
>>>>5 ubyte <9
>>>>>6 ubyte 0
>>>>>>7 ubyte x \b, codec=%d RGB color palettes
>>>>>6 ubyte 64 \b, codec=RGB fixed color
>>>>>6 ubyte 128 \b, codec=YJK
>>>>>6 ubyte 192 \b, codec=YUV
>>>>5 ubyte >8 codec=RGB fixed color
>>>>12 ubyte 0 \b, raw
>>>>12 ubyte 1 \b, bitbuster compression
############## Other MSX file formats ##############
# MSX ROMs
0 string 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
>>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
>>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
>>8 uleshort >0 \b, bas=0x%04x
0 string 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
0x4000 string AB
>0x4002 uleshort >0x4010
>>0x400A string \0\0\0\0\0\0 MSX MegaROM 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
>>0x4008 uleshort >0 \b, bas=0x%04x
0x8000 string AB
>0x8002 uleshort >0x4010
>>0x800A string \0\0\0\0\0\0 MSX MegaROM 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
>>0x8008 uleshort >0 \b, bas=0x%04x
0x3C000 string 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
>>0x3C008 uleshort >0 \b, bas=0x%04x
# MSX BIN file
#0 byte 0xFE
#>1 uleshort >0x8000
#>>3 uleshort >0x8004
#>>>5 uleshort >0x8000 MSX BIN file
# MSX-BASIC file
0 byte 0xFF
>3 uleshort 0x000A
>>1 uleshort >0x8000 MSX-BASIC program
# MSX .CAS file
0 string \x1F\xA6\xDE\xBA\xCC\x13\x7D\x74 MSX cassette archive
# Mega-Assembler file
0 byte 0xFE
>1 uleshort 0x0001
>>5 uleshort 0xffff
>>>6 byte 0x0A MSX Mega-Assembler source
# Execrom Patchfile
0 string ExecROM\ patchfile\x1A MSX ExecROM patchfile
>0x12 ubyte/16 x v%d
>0x12 ubyte&0xF x \b.%d
>0x13 ubyte x \b, contains %d patches
# Konami's King's Valley-2 custom stage (ELG file)
4 uleshort 0x0900
>0xF byte 1
>>0x14 byte 0
>>>0x1E string \ \ \
>>>>0x23 byte 1
>>>>>0x25 byte 0
>>>>>>0x15 string >\x30
>>>>>>>0x15 string <\x5A Konami King's Valley-2 custom stage, title: "%-8.8s"
>>>>>>>>0x1D byte <32 \b, theme: %d
# Metal Gear 1 savegame
#0x4F string \x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF
#>>0x60 string \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF
#>>>0x7B string \0x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00 Metal Gear 1 savegame

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: pdf,v 1.6 2009/09/19 16:28:11 christos Exp $
# $File: pdf,v 1.7 2013/08/22 07:47:26 christos Exp $
# pdf: file(1) magic for Portable Document Format
#
@ -12,5 +12,6 @@
# From: Nick Schmalenberger <nick@schmalenberger.us>
# Forms Data Format
0 string %FDF- FDF document
!:mime application/vnd.fdf
>5 byte x \b, version %c
>7 byte x \b.%c

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: pdp,v 1.8 2009/09/19 16:28:11 christos Exp $
# $File: pdp,v 1.9 2013/04/19 20:11:43 christos Exp $
# pdp: file(1) magic for PDP-11 executable/object and APL workspace
#
0 lelong 0101555 PDP-11 single precision APL workspace
@ -12,7 +12,13 @@
>8 leshort >0 not stripped
>15 byte >0 - version %ld
0 leshort 0401 PDP-11 UNIX/RT ldp
# updated by Joerg Jenderek at Mar 2013
# GRR: line below too general as it catches also Windows precompiled setup information *.PNF
0 leshort 0401
# skip *.PNF with WinDirPathOffset 58h
>68 ulelong !0x00000058 PDP-11 UNIX/RT ldp
# skip *.PNF with high byte of InfVersionDatumCount zero
#>>15 byte !0 PDP-11 UNIX/RT ldp
0 leshort 0405 PDP-11 old overlay
0 leshort 0410 PDP-11 pure executable

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: riff,v 1.23 2013/02/06 14:18:52 christos Exp $
# $File: riff,v 1.24 2013/11/19 23:58:17 christos Exp $
# riff: file(1) magic for RIFF format
# See
#
@ -55,6 +55,8 @@
# Corel Draw Picture
>8 string CDRA \b, Corel Draw Picture
!:mime image/x-coreldraw
>8 string CDR6 \b, Corel Draw Picture, version 6
!:mime image/x-coreldraw
# AVI == Audio Video Interleave
>8 string AVI\040 \b, AVI
!:mime video/x-msvideo
@ -220,6 +222,7 @@
>>24 belong >0 %d Hz
# Corel Draw Picture
>8 string CDRA \b, Corel Draw Picture
>8 string CDR6 \b, Corel Draw Picture, version 6
# AVI == Audio Video Interleave
>8 string AVI\040 \b, AVI
# Animated Cursor format

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: sql,v 1.11 2013/02/21 15:27:01 christos Exp $
# $File: sql,v 1.13 2013/08/27 04:02:33 christos Exp $
# sql: file(1) magic for SQL files
#
# From: "Marty Leisner" <mleisner@eng.mc.xerox.com>
@ -50,12 +50,30 @@
0 string **\ This\ file\ contains\ an\ SQLite SQLite 2.x database
# Version 3 of SQLite allows applications to embed their own "user version"
# number in the database. Detect this and distinguish those files.
# number in the database at offset 60. Later, SQLite added an "application id"
# at offset 68 that is preferred over "user version" for indicating the
# associated application.
#
0 string SQLite\ format\ 3
>60 string _MTN Monotone source repository
>60 belong !0 SQLite 3.x database, user version %u
>60 belong 0 SQLite 3.x database
>60 belong =0x5f4d544e Monotone source repository - SQLite3 database
>68 belong =0x0f055112 Fossil checkout - SQLite3 database
>68 belong =0x0f055113 Fossil global configuration - SQLite3 database
>68 belong =0x0f055111 Fossil repository - SQLite3 database
>68 belong =0x42654462 Bentley Systems BeSQLite Database - SQLite3 database
>68 belong =0x42654c6e Bentley Systems Localization File - SQLite3 database
>68 belong =0x47504b47 OGC GeoPackage file - SQLite3 database
>68 default x SQLite 3.x database
>>68 belong !0 \b, application id %u
>>60 belong !0 \b, user version %d
# SQLite Write-Ahead Log from SQLite version >= 3.7.0
# http://www.sqlite.org/fileformat.html#walformat
0 belong&0xfffffffe 0x377f0682 SQLite Write-Ahead Log,
>4 belong x version %ld
# SQLite Rollback Journal
# http://www.sqlite.org/fileformat.html#rollbackjournal
0 string \xd9\xd5\x05\xf9\x20\xa1\x63\xd7 SQLite Rollback Journal
# Panasonic channel list database svl.bin or svl.db added by Joerg Jenderek
# http://www.ullrich.es/job/service-menue/panasonic/panasonic-sendersortierung-sat-am-pc/

View File

@ -6,3 +6,6 @@
0 string ssh-dss\ OpenSSH DSA public key
0 string ssh-rsa\ OpenSSH RSA public key
0 string ecdsa-sha2-nistp256 OpenSSH ECDSA public key
0 string ecdsa-sha2-nistp384 OpenSSH ECDSA public key
0 string ecdsa-sha2-nistp521 OpenSSH ECDSA public key

View File

@ -5,3 +5,4 @@
0 string -----BEGIN\ CERTIFICATE\ REQ PEM certificate request
0 string -----BEGIN\ RSA\ PRIVATE PEM RSA private key
0 string -----BEGIN\ DSA\ PRIVATE PEM DSA private key
0 string -----BEGIN\ EC\ PRIVATE PEM EC private key

View File

@ -0,0 +1,42 @@
#------------------------------------------------------------------------------
# msx: file(1) magic for the SymbOS operating system
# http://www.symbos.de
# Fábio R. Schmidlin <frs@pop.com.br>
# SymbOS EXE file
0x30 string SymExe SymbOS executable
>0x36 ubyte x v%c
>0x37 ubyte x \b.%c
>0xF string x \b, name: %s
# SymbOS DOX document
0 string INFOq\0 SymbOS DOX document
# Symbos driver
0 string SMD1 SymbOS driver
>19 byte x \b, name: %c
>20 byte x \b%c
>21 byte x \b%c
>22 byte x \b%c
>23 byte x \b%c
>24 byte x \b%c
>25 byte x \b%c
>26 byte x \b%c
>27 byte x \b%c
>28 byte x \b%c
>29 byte x \b%c
>30 byte x \b%c
>31 byte x \b%c
# Symbos video
0 string SymVid SymbOS video
>6 ubyte x v%c
>7 ubyte x \b.%c
# Soundtrakker 128 ST2 music
0 byte 0
>0xC string \x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x40\x00 Soundtrakker 128 ST2 music,
>>1 string x name: %s

View File

@ -1,10 +1,12 @@
#------------------------------------------------------------------------
# $File: sysex,v 1.6 2009/09/19 16:28:12 christos Exp $
# $File: sysex,v 1.7 2013/09/16 15:12:42 christos Exp $
# sysex: file(1) magic for MIDI sysex files
#
#
0 byte 0xF0 SysEx File -
# GRR: orginal 1 byte test at offset was too general as it catches also many FATs of DOS filesystems
# where real SYStem EXclusive messages at offset 1 are limited to seven bits
# http://en.wikipedia.org/wiki/MIDI
0 ubeshort&0xFF80 0xF000 SysEx File -
# North American Group
>1 byte 0x01 Sequential
@ -210,7 +212,7 @@
>1 byte 0x52 Zoom
>1 byte 0x54 Matsushita
>1 byte 0x57 Acoustic tech. lab.
# http://www.midi.org/techspecs/manid.php
>1 belong&0xffffff00 0x00007400 Ta Horng
>1 belong&0xffffff00 0x00007500 e-Tek
>1 belong&0xffffff00 0x00007600 E-Voice

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: tex,v 1.18 2011/02/08 13:45:15 christos Exp $
# $File: tex,v 1.19 2013/09/17 17:39:16 christos Exp $
# tex: file(1) magic for TeX files
#
# XXX - needs byte-endian stuff (big-endian and little-endian DVI?)
@ -40,6 +40,9 @@
0 search/4096 \\input TeX document text
!:mime text/x-tex
!:strength + 15
0 search/4096 \\begin LaTeX document text
!:mime text/x-tex
!:strength + 15
0 search/4096 \\section LaTeX document text
!:mime text/x-tex
!:strength + 18

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: windows,v 1.5 2012/04/03 22:25:07 christos Exp $
# $File: windows,v 1.6 2013/04/19 20:12:29 christos Exp $
# windows: file(1) magic for Microsoft Windows
#
# This file is mainly reserved for files where programs
@ -158,8 +158,179 @@
0 string Windows\ Registry\ Editor\
>&0 string Version\ 5.00\r\n\r\n Windows Registry text (Win2K or above)
# Windows *.INF *.INI files updated by Joerg Jenderek at Apr 2013
# emtpy ,comment , section , unicode line
0 regex/s \\`(\r\n|;|[[]|\xFF\xFE)
# left bracket in section line
>&0 search/8192 [
# http://en.wikipedia.org/wiki/Autorun.inf
# http://msdn.microsoft.com/en-us/library/windows/desktop/cc144200.aspx
>>&0 regex/c \^(autorun)]\r\n
>>>&0 ubyte =0x5b INItialization configuration
!:mime application/x-wine-extension-ini
# From: Pal Tamas <folti@balabit.hu>
# Autorun File
0 string/c [autorun]\r\n Microsoft Windows Autorun file.
!:mime application/x-setupscript.
>>>&0 ubyte !0x5b Microsoft Windows Autorun file
!:mime application/x-setupscript
# http://msdn.microsoft.com/en-us/library/windows/hardware/ff549520(v=vs.85).aspx
# version strings ASCII coded case-independent for Windows setup information script file
>>&0 regex/c \^(version|strings)] Windows setup INFormation
!:mime application/x-setupscript
#!:mime application/inf
#!:mime application/x-wine-extension-inf
>>&0 regex/c \^(WinsockCRCList|OEMCPL)] Windows setup INFormation
!:mime text/inf
# http://www.winfaq.de/faq_html/Content/tip2500/onlinefaq.php?h=tip2653.htm
# http://msdn.microsoft.com/en-us/library/windows/desktop/cc144102.aspx
# .ShellClassInfo DeleteOnCopy LocalizedFileNames ASCII coded case-independent
>>&0 regex/c \^(\.ShellClassInfo|DeleteOnCopy|LocalizedFileNames)] Windows desktop.ini
!:mime application/x-wine-extension-ini
#!:mime text/plain
# http://support.microsoft.com/kb/84709/
>>&0 regex/c \^(don't\ load)] Windows CONTROL.INI
!:mime application/x-wine-extension-ini
>>&0 regex/c \^(ndishlp\\$|protman\\$|NETBEUI\\$)] Windows PROTOCOL.INI
!:mime application/x-wine-extension-ini
# http://technet.microsoft.com/en-us/library/cc722567.aspx
# http://www.winfaq.de/faq_html/Content/tip0000/onlinefaq.php?h=tip0137.htm
>>&0 regex/c \^(windows|Compatibility|embedding)] Windows WIN.INI
!:mime application/x-wine-extension-ini
# http://en.wikipedia.org/wiki/SYSTEM.INI
>>&0 regex/c \^(boot|386enh|drivers)] Windows SYSTEM.INI
!:mime application/x-wine-extension-ini
# http://www.mdgx.com/newtip6.htm
>>&0 regex/c \^(SafeList)] Windows IOS.INI
!:mime application/x-wine-extension-ini
# http://en.wikipedia.org/wiki/NTLDR Windows Boot Loader information
>>&0 regex/c \^(boot\x20loader)] Windows boot.ini
!:mime application/x-wine-extension-ini
>>>&0 ubyte x
# http://en.wikipedia.org/wiki/CONFIG.SYS
>>&0 regex/c \^(menu)]\r\n MS-DOS CONFIG.SYS
# http://support.microsoft.com/kb/118579/
>>&0 regex/c \^(Paths)]\r\n MS-DOS MSDOS.SYS
# VERS string unicoded case-independent
>>&0 ubequad&0xFFdfFFdfFFdfFFdf 0x0056004500520053
# ION] string unicoded case-independent
>>>&0 ubequad&0xFFdfFFdfFFdfFFff 0x0049004f004e005d Windows setup INFormation
!:mime application/x-setupscript
# STRI string unicoded case-independent
>>&0 ubequad&0xFFdfFFdfFFdfFFdf 0x0053005400520049
# NGS] string unicoded case-independent
>>>&0 ubequad&0xFFdfFFdfFFdfFFff 0x004e00470053005D Windows setup INFormation
!:mime application/x-setupscript
# unknown keyword after opening bracket
>>&0 default x
>>>&0 search/8192 [
# version Strings FileIdentification
>>>>&0 string/c version Windows setup INFormation
!:mime application/x-setupscript
# VERS string unicoded case-independent
>>>>&0 ubequad&0xFFdfFFdfFFdfFFdf 0x0056004500520053
# ION] string unicoded case-independent
>>>>>&0 ubequad&0xFFdfFFdfFFdfFFff 0x0049004f004e005d Windows setup INFormation
!:mime application/x-setupscript
# http://en.wikipedia.org/wiki/Initialization_file Windows Initialization File or other
#>>>>&0 default x Generic INItialization configuration
#!:mime application/x-wine-extension-ini
# Windows Precompiled INF files *.PNF added by Joerg Jenderek at Mar 2013 of _PNF_HEADER inf.h
# http://read.pudn.com/downloads3/sourcecode/windows/248345/win2k/private/windows/setup/setupapi/inf.h__.htm
# GRR: line below too general as it catches also PDP-11 UNIX/RT ldp
0 leshort&0xFeFe 0x0000
# test for unused null bits in PNF_FLAGs
>4 ulelong&0xFCffFe00 0x00000000
# only found 58h for Offset of WinDirPath immediately after _PNF_HEADER structure
>>68 ulelong >0x57
# test for zero high byte of InfValueBlockSize, followed by WinDirPath like
# C:\WINDOWS (ASCII 0x433a5c.. , unicode 0x43003a005c..) or X:\MININT
>>>(68.l-1) ubelong&0xffE0C519 =0x00400018 Windows Precompiled iNF
!:mime application/x-pnf
# currently only found Major Version=1 and Minor Version=1
#>>>>0 uleshort =0x0101
#>>>>>1 ubyte x \b, version %u
#>>>>>0 ubyte x \b.%u
>>>>0 uleshort !0x0101
>>>>>1 ubyte x \b, version %u
>>>>>0 ubyte x \b.%u
# 1 ,2 (windows 98 SE)
#>>>>2 uleshort =2 \b, InfStyle %u
>>>>2 uleshort !2 \b, InfStyle %u
# PNF_FLAG_IS_UNICODE 0x00000001
# PNF_FLAG_HAS_STRINGS 0x00000002
# PNF_FLAG_SRCPATH_IS_URL 0x00000004
# PNF_FLAG_HAS_VOLATILE_DIRIDS 0x00000008
# PNF_FLAG_INF_VERIFIED 0x00000010
# PNF_FLAG_INF_DIGITALLY_SIGNED 0x00000020
# ?? 0x00000100
# ?? 0x01000000
# ?? 0x02000000
>>>>4 ulelong&0x00000001 0x00000001 \b, unicoded
>>>>4 ulelong&0x00000020 0x00000020 \b, digitally signed
#>>>>8 ulelong x \b, InfSubstValueListOffset 0x%x
# many 0, 1 lmouusb.PNF, 2 linkfx10.PNF , f webfdr16.PNF
#>>>>12 uleshort x \b, InfSubstValueCount 0x%x
# only < 9 found
#>>>>14 uleshort x \b, InfVersionDatumCount 0x%x
# only found values lower 0x0000ffff
#>>>>16 ulelong x \b, InfVersionDataSize 0x%x
# only found positive values lower 0x00ffFFff for InfVersionDataOffset
>>>>20 ulelong x \b, at 0x%x
>>>>4 ulelong&0x00000001 =0x00000001
# case independent: CatalogFile Class DriverVer layoutfile LayoutFile SetupClass signature Signature
>>>>>(20.l) lestring16 x "%s"
>>>>4 ulelong&0x00000001 !0x00000001
>>>>>(20.l) string x "%s"
# FILETIME is number of 100-nanosecond intervals since 1 January 1601
#>>>>24 ulequad x \b, InfVersionLastWriteTime %16.16llx
# only found values lower 0x00ffFFff
#>>>>32 ulelong x \b, StringTableBlockOffset 0x%x
#>>>>36 ulelong x \b, StringTableBlockSize 0x%x
#>>>>40 ulelong x \b, InfSectionCount 0x%x
#>>>>44 ulelong x \b, InfSectionBlockOffset 0x%x
#>>>>48 ulelong x \b, InfSectionBlockSize 0x%x
#>>>>52 ulelong x \b, InfLineBlockOffset 0x%x
#>>>>56 ulelong x \b, InfLineBlockSize 0x%x
#>>>>60 ulelong x \b, InfValueBlockOffset 0x%x
#>>>>64 ulelong x \b, InfValueBlockSize 0x%x
# WinDirPathOffset
#>>>>68 ulelong x \b, at 0x%x
>>>>68 ulelong >0x57
>>>>>4 ulelong&0x00000001 =0x00000001
>>>>>>(68.l) ubequad =0x43003a005c005700
# normally unicoded C:\Windows
#>>>>>>>(68.l) lestring16 x \b, WinDirPath "%s"
>>>>>>(68.l) ubequad !0x43003a005c005700
>>>>>>>(68.l) lestring16 x \b, WinDirPath "%s"
>>>>>4 ulelong&0x00000001 !0x00000001
# normally ASCII C:\WINDOWS
#>>>>>>(68.l) string =C:\\WINDOWS \b, WinDirPath "%s"
>>>>>>(68.l) string !C:\\WINDOWS \b, WinDirPath "%s"
# found OsLoaderPathOffset values often 0 , once 70h corelist.PNF, once 68h ASCII machine.PNF
#>>>>72 ulelong >0 \b, at 0x%x
>>>>72 ulelong >0 \b,
>>>>>4 ulelong&0x00000001 =0x00000001
>>>>>>(72.l) lestring16 x OsLoaderPath "%s"
>>>>>4 ulelong&0x00000001 !0x00000001
# seldom C:\ instead empty
>>>>>>(72.l) string x OsLoaderPath "%s"
# 1fdh
#>>>>76 uleshort x \b, StringTableHashBucketCount 0x%x
>>>>78 uleshort !0x407 \b, LanguageId %x
# only 407h found
#>>>>78 uleshort =0x407 \b, LanguageId %x
# InfSourcePathOffset often 0
#>>>>80 ulelong >0 \b, at 0x%x
>>>>80 ulelong >0 \b,
>>>>>4 ulelong&0x00000001 =0x00000001
>>>>>>(80.l) lestring16 x SourcePath "%s"
>>>>>4 ulelong&0x00000001 !0x00000001
>>>>>>(80.l) string >\0 SourcePath "%s"
# OriginalInfNameOffset often 0
#>>>>84 ulelong >0 \b, at 0x%x
>>>>84 ulelong >0 \b,
>>>>>4 ulelong&0x00000001 =0x00000001
>>>>>>(84.l) lestring16 x InfName "%s"
>>>>>4 ulelong&0x00000001 !0x00000001
>>>>>>(84.l) string >\0 InfName "%s"

View File

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: wordprocessors,v 1.17 2013/02/06 14:18:52 christos Exp $
# $File: wordprocessors,v 1.18 2013/06/03 19:07:29 christos Exp $
# wordprocessors: file(1) magic fo word processors.
#
####### PWP file format used on Smith Corona Personal Word Processors:
@ -156,6 +156,11 @@
0 string/w \<map\ version Freemind document
!:mime application/x-freemind
# Type: Freeplane mindmap documents
# From: Felix Natter <fnatter@gmx.net>
0 string/w \<map\ version="freeplane Freeplane document
!:mime application/x-freeplane
# Type: Scribus
# From: Werner Fink <werner@suse.de>
0 string \<SCRIBUSUTF8\ Version Scribus Document

View File

@ -1,38 +1,40 @@
#------------------------------------------------------------------------------
# $File: xilinx,v 1.5 2013/01/08 03:06:50 christos Exp $
# $File: xilinx,v 1.6 2013/11/19 23:15:13 christos Exp $
# This is Aaron's attempt at a MAGIC file for Xilinx .bit files.
# Xilinx-Magic@RevRagnarok.com
# Got the info from FPGA-FAQ 0026
#
# Rewritten to use pstring/H instead of hardcoded lengths by O. Freyermuth,
# fixes at least reading of bitfiles from Spartan 2, 3, 6.
# http://www.fpga-faq.com/FAQ_Pages/0026_Tell_me_about_bit_files.htm
#
# First there is the sync header and its length
0 beshort 0x0009
>2 belong =0x0ff00ff0
>>&0 belong =0x0ff00ff0
>>>&0 beshort =0x0000
>>>>&0 pstring a Xilinx BIT data
>>>&0 byte =0x00
>>>&1 beshort =0x0001
>>>&3 string a Xilinx BIT data
# Next is a Pascal-style string with the NCD name. We want to capture that.
>>>>0x0F pstring x - from %s
# It is followed by a NUL
>>>>>&1 byte 0x00
>>>>&0 pstring/H x - from %s
# And then 'b'
>>>>>&2 string b
# With the part number:
#>>>>>&5 string 4v (Virtex4)
#>>>>>&5 string 2v (Virtex II
#>>>>>>&0 string !p \b)
#>>>>>>&0 string p Pro)
>>>>>&4 pstring x - for %s
# And then NUL / 'c' / Build Data / NUL / 'd' / Date / NUL / 'e' / Data Length
>>>>>>&1 byte 0x00
>>>>>>&2 string c
>>>>>>&4 pstring x - built %s
>>>>>>>&1 byte 0x00
>>>>>>>&2 string d
>>>>>>>&4 pstring x \b(%s)
>>>>>>>>&1 byte 0x00
>>>>>>>>&2 string e
>>>>>>>>&4 belong x - data length 0x%lx
>>>>>&1 string b
# Then the model / part number:
>>>>>>&0 pstring/H x - for %s
# Then 'c'
>>>>>>>&1 string c
# Then the build-date
>>>>>>>>&0 pstring/H x - built %s
# Then 'd'
>>>>>>>>>&1 string d
# Then the build-time
>>>>>>>>>>&0 pstring/H x \b(%s)
# Then 'e'
>>>>>>>>>>>&1 string e
# And length of data
>>>>>>>>>>>>&0 belong x - data length 0x%lx
# Raw bitstream files
0 long 0xffffffff
>&0 belong 0xaa995566 Xilinx RAW bitstream (.BIN)
0 long 0xffffffff
>&0 belong 0xaa995566 Xilinx RAW bitstream (.BIN)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ascmagic.c,v 1.1.1.4 2013/01/03 16:27:52 christos Exp $ */
/* $NetBSD: ascmagic.c,v 1.1.1.5 2013/12/01 19:28:16 christos Exp $ */
/*
* Copyright (c) Ian F. Darwin 1986-1995.
@ -38,9 +38,9 @@
#ifndef lint
#if 0
FILE_RCSID("@(#)$File: ascmagic.c,v 1.85 2012/08/09 16:33:15 christos Exp $")
FILE_RCSID("@(#)$File: ascmagic.c,v 1.87 2013/09/17 15:51:22 christos Exp $")
#else
__RCSID("$NetBSD: ascmagic.c,v 1.1.1.4 2013/01/03 16:27:52 christos Exp $");
__RCSID("$NetBSD: ascmagic.c,v 1.1.1.5 2013/12/01 19:28:16 christos Exp $");
#endif
#endif /* lint */
@ -78,7 +78,7 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
int text)
{
unichar *ubuf = NULL;
size_t ulen;
size_t ulen = 0;
int rv = 1;
const char *code = NULL;
@ -217,6 +217,7 @@ file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf,
case 0:
if (file_printf(ms, ", ") == -1)
goto done;
break;
case -1:
goto done;
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: encoding.c,v 1.1.1.3 2012/02/22 17:48:23 christos Exp $ */
/* $NetBSD: encoding.c,v 1.1.1.4 2013/12/01 19:28:16 christos Exp $ */
/*
* Copyright (c) Ian F. Darwin 1986-1995.
@ -38,9 +38,9 @@
#ifndef lint
#if 0
FILE_RCSID("@(#)$File: encoding.c,v 1.7 2012/01/24 19:02:02 christos Exp $")
FILE_RCSID("@(#)$File: encoding.c,v 1.9 2013/11/19 20:45:50 christos Exp $")
#else
__RCSID("$NetBSD: encoding.c,v 1.1.1.3 2012/02/22 17:48:23 christos Exp $");
__RCSID("$NetBSD: encoding.c,v 1.1.1.4 2013/12/01 19:28:16 christos Exp $");
#endif
#endif /* lint */
@ -78,13 +78,17 @@ file_encoding(struct magic_set *ms, const unsigned char *buf, size_t nbytes, uni
unsigned char *nbuf = NULL;
*type = "text";
mlen = (nbytes + 1) * sizeof(nbuf[0]);
if ((nbuf = CAST(unsigned char *, calloc((size_t)1, mlen))) == NULL) {
*ulen = 0;
*code = "unknown";
*code_mime = "binary";
mlen = (nbytes + 1) * sizeof((*ubuf)[0]);
if ((*ubuf = CAST(unichar *, calloc((size_t)1, mlen))) == NULL) {
file_oomem(ms, mlen);
goto done;
}
mlen = (nbytes + 1) * sizeof((*ubuf)[0]);
if ((*ubuf = CAST(unichar *, calloc((size_t)1, mlen))) == NULL) {
mlen = (nbytes + 1) * sizeof(nbuf[0]);
if ((nbuf = CAST(unsigned char *, calloc((size_t)1, mlen))) == NULL) {
file_oomem(ms, mlen);
goto done;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: file.c,v 1.1.1.5 2013/03/23 15:49:16 christos Exp $ */
/* $NetBSD: file.c,v 1.1.1.6 2013/12/01 19:28:17 christos Exp $ */
/*
* Copyright (c) Ian F. Darwin 1986-1995.
@ -35,9 +35,9 @@
#ifndef lint
#if 0
FILE_RCSID("@(#)$File: file.c,v 1.149 2013/01/07 18:20:19 christos Exp $")
FILE_RCSID("@(#)$File: file.c,v 1.152 2013/06/26 14:46:54 christos Exp $")
#else
__RCSID("$NetBSD: file.c,v 1.1.1.5 2013/03/23 15:49:16 christos Exp $");
__RCSID("$NetBSD: file.c,v 1.1.1.6 2013/12/01 19:28:17 christos Exp $");
#endif
#endif /* lint */
@ -471,8 +471,11 @@ file_mbswidth(const char *s)
* is always right
*/
width++;
} else
width += wcwidth(nextchar);
} else {
int w = wcwidth(nextchar);
if (w > 0)
width += w;
}
s += bytesconsumed, n -= bytesconsumed;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: file_opts.h,v 1.1.1.3 2013/01/03 16:27:52 christos Exp $ */
/* $NetBSD: file_opts.h,v 1.1.1.4 2013/12/01 19:28:17 christos Exp $ */
/*
* Table of command-line options
@ -34,8 +34,8 @@ OPT_LONGONLY("apple", 0, " output the Apple CREATOR/TYPE\n")
OPT_LONGONLY("mime-type", 0, " output the MIME type\n")
OPT_LONGONLY("mime-encoding", 0, " output the MIME encoding\n")
OPT('k', "keep-going", 0, " don't stop at the first match\n")
#ifdef S_IFLNK
OPT('l', "list", 0, " list magic strength\n")
#ifdef S_IFLNK
OPT('L', "dereference", 0, " follow symlinks (default)\n")
OPT('h', "no-dereference", 0, " don't follow symlinks\n")
#endif

View File

@ -65,6 +65,7 @@
MAGIC_NO_CHECK_CDF | \
MAGIC_NO_CHECK_TOKENS | \
MAGIC_NO_CHECK_ENCODING | \
0 \
)
/* Defined for backwards compatibility (renamed) */

View File

@ -1,18 +1,18 @@
/* $NetBSD: pread.c,v 1.1.1.1 2013/03/23 15:49:15 christos Exp $ */
/* $NetBSD: pread.c,v 1.1.1.2 2013/12/01 19:28:16 christos Exp $ */
#include "file.h"
#ifndef lint
#if 0
FILE_RCSID("@(#)$File: pread.c,v 1.1 2013/02/18 15:40:59 christos Exp $")
FILE_RCSID("@(#)$File: pread.c,v 1.2 2013/04/02 16:23:07 christos Exp $")
#else
__RCSID("$NetBSD: pread.c,v 1.1.1.1 2013/03/23 15:49:15 christos Exp $");
__RCSID("$NetBSD: pread.c,v 1.1.1.2 2013/12/01 19:28:16 christos Exp $");
#endif
#endif /* lint */
#include <fcntl.h>
#include <unistd.h>
ssize_t
pread(int fd, void *buf, ssize_t len, off_t off) {
pread(int fd, void *buf, size_t len, off_t off) {
if (lseek(fd, off, SEEK_SET) == (off_t)-1)
return -1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: readelf.h,v 1.1.1.3 2013/03/23 15:49:15 christos Exp $ */
/* $NetBSD: readelf.h,v 1.1.1.4 2013/12/01 19:28:16 christos Exp $ */
/*
* Copyright (c) Christos Zoulas 2003.
@ -257,6 +257,46 @@ typedef struct {
*/
#define NT_GNU_BUILD_ID 3
/*
* NetBSD-specific note type: PaX.
* There should be 1 NOTE per executable.
* name: PaX\0
* namesz: 4
* desc:
* word[0]: capability bitmask
* descsz: 4
*/
#define NT_NETBSD_PAX 3
#define NT_NETBSD_PAX_MPROTECT 0x01 /* Force enable Mprotect */
#define NT_NETBSD_PAX_NOMPROTECT 0x02 /* Force disable Mprotect */
#define NT_NETBSD_PAX_GUARD 0x04 /* Force enable Segvguard */
#define NT_NETBSD_PAX_NOGUARD 0x08 /* Force disable Servguard */
#define NT_NETBSD_PAX_ASLR 0x10 /* Force enable ASLR */
#define NT_NETBSD_PAX_NOASLR 0x20 /* Force disable ASLR */
/*
* NetBSD-specific note type: MACHINE_ARCH.
* There should be 1 NOTE per executable.
* name: NetBSD\0
* namesz: 7
* desc: string
* descsz: variable
*/
#define NT_NETBSD_MARCH 5
/*
* NetBSD-specific note type: COMPILER MODEL.
* There should be 1 NOTE per executable.
* name: NetBSD\0
* namesz: 7
* desc: string
* descsz: variable
*/
#define NT_NETBSD_CMODEL 6
#if !defined(ELFSIZE) && defined(ARCH_ELFSIZE)
#define ELFSIZE ARCH_ELFSIZE
#endif
/* SunOS 5.x hardware/software capabilities */
typedef struct {
Elf32_Word c_tag;