cherry-pick.FILE5_29-23-gc8ef8f4.combined.patch 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. Subject: Combined patch of all commits since the 5.29 release
  2. Origin: FILE5_29..FILE5_29-23-gc8ef8f4
  3. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Sat Dec 10 14:21:29 2016 +0000
  5. --- a/ChangeLog
  6. +++ b/ChangeLog
  7. @@ -1,6 +1,11 @@
  8. +2016-11-06 10:52 Christos Zoulas <christos@zoulas.com>
  9. +
  10. + * Allow @@@ in extensions
  11. + * Add missing overflow check in der magic (Jonas Wagner)
  12. +
  13. 2016-10-25 10:40 Christos Zoulas <christos@zoulas.com>
  14. - * release 5.28
  15. + * release 5.29
  16. 2016-10-24 11:20 Christos Zoulas <christos@zoulas.com>
  17. --- a/doc/magic.man
  18. +++ b/doc/magic.man
  19. @@ -7,7 +7,7 @@
  20. .Nm magic
  21. .Nd file command's magic pattern file
  22. .Sh DESCRIPTION
  23. -This manual page documents the format of the magic file as
  24. +This manual page documents the format of magic files as
  25. used by the
  26. .Xr file __CSECTION__
  27. command, version __VERSION__.
  28. @@ -17,13 +17,19 @@
  29. among other tests,
  30. a test for whether the file contains certain
  31. .Dq "magic patterns" .
  32. -The file
  33. -.Pa __MAGIC__
  34. -specifies what patterns are to be tested for, what message or
  35. +The database of these
  36. +.Dq "magic patterns"
  37. +is usually located in a binary file in
  38. +.Pa __MAGIC__.mgc
  39. +or a directory of source text magic pattern fragment files in
  40. +.Pa __MAGIC__ .
  41. +The database specifies what patterns are to be tested for, what message or
  42. MIME type to print if a particular pattern is found,
  43. and additional information to extract from the file.
  44. .Pp
  45. -Each line of the file specifies a test to be performed.
  46. +The format of the source fragment files that are used to build this database
  47. +is as follows:
  48. +Each line of a fragment file specifies a test to be performed.
  49. A test compares the data starting at a particular offset
  50. in the file with a byte value, a string or a numeric value.
  51. If the test succeeds, a message is printed.
  52. --- a/magic/Magdir/audio
  53. +++ b/magic/Magdir/audio
  54. @@ -469,6 +469,8 @@
  55. >>20 byte&0xe 0xc \b, 7 channels
  56. >>20 byte&0xe 0xe \b, 8 channels
  57. # some common sample rates
  58. +>>17 belong&0xfffff0 0x2ee000 \b, 192 kHz
  59. +>>17 belong&0xfffff0 0x158880 \b, 88.2 kHz
  60. >>17 belong&0xfffff0 0x0ac440 \b, 44.1 kHz
  61. >>17 belong&0xfffff0 0x0bb800 \b, 48 kHz
  62. >>17 belong&0xfffff0 0x07d000 \b, 32 kHz
  63. --- a/magic/Magdir/console
  64. +++ b/magic/Magdir/console
  65. @@ -617,6 +617,52 @@
  66. >0x218 belong 0x5D1C9EA3 Nintendo Wii disc image (WBFS format):
  67. >>0x200 use nintendo-gcn-disc-common
  68. +# Type: Nintendo GameCube/Wii disc image (CISO format)
  69. +# NOTE: This is NOT the same as Compact ISO or PSP CISO,
  70. +# though it has the same magic number.
  71. +0 string CISO
  72. +# Other fields are used to determine what type of CISO this is:
  73. +# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size)
  74. +# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size)
  75. +# - None of the above: Compact ISO.
  76. +>4 lelong 0x200000
  77. +>>8 byte 1
  78. +>>>0x801C belong 0xC2339F3D Nintendo GameCube disc image (CISO format):
  79. +>>>>0x8000 use nintendo-gcn-disc-common
  80. +>>>0x8018 belong 0x5D1C9EA3 Nintendo Wii disc image (CISO format):
  81. +>>>>0x8000 use nintendo-gcn-disc-common
  82. +
  83. +# Type: Nintendo GameCube/Wii disc image (GCZ format)
  84. +# Due to zlib compression, we can't get the actual disc information.
  85. +0 lelong 0xB10BC001
  86. +>4 lelong 0 Nintendo GameCube disc image (GCZ format)
  87. +>4 lelong 1 Nintendo Wii disc image (GCZ format)
  88. +>4 lelong >1 Nintendo GameCube/Wii disc image (GCZ format)
  89. +
  90. +# Type: Nintendo GameCube/Wii disc image (WDF format)
  91. +0 string WII\001DISC
  92. +>8 belong 1
  93. +# WDFv1
  94. +>>0x54 belong 0xC2339F3D Nintendo GameCube disc image (WDFv1 format):
  95. +>>>0x38 use nintendo-gcn-disc-common
  96. +>>0x58 belong 0x5D1C9EA3 Nintendo Wii disc image (WDFv1 format):
  97. +>>>0x38 use nintendo-gcn-disc-common
  98. +>8 belong 2
  99. +# WDFv2
  100. +>>(12.L+0x1C) belong 0xC2339F3D Nintendo GameCube disc image (WDFv2 format):
  101. +>>>(12.L) use nintendo-gcn-disc-common
  102. +>>(12.L+0x18) belong 0x5D1C9EA3 Nintendo Wii disc image (WDFv2 format):
  103. +>>>(12.L) use nintendo-gcn-disc-common
  104. +
  105. +# Type: Nintendo GameCube/Wii disc image (WIA format)
  106. +0 string WIA\001 Nintendo
  107. +>0x48 belong 0 GameCube/Wii
  108. +>0x48 belong 1 GameCube
  109. +>0x48 belong 2 Wii
  110. +>0x48 belong >2 GameCube/Wii
  111. +>0x48 belong x disc image (WIA format):
  112. +>>0x58 use nintendo-gcn-disc-common
  113. +
  114. #------------------------------------------------------------------------------
  115. # Nintendo 3DS file formats.
  116. #
  117. @@ -750,3 +796,17 @@
  118. #
  119. 0 string g\ GCE Vectrex ROM image
  120. >0x11 string >\0 \b: "%.16s"
  121. +
  122. +#------------------------------------------------------------------------------
  123. +# amiibo: file(1) magic for Nintendo amiibo NFC dumps.
  124. +# From: David Korth <gerbilsoft@gerbilsoft.com>
  125. +# Reference: https://www.3dbrew.org/wiki/Amiibo
  126. +0x00 byte 0x04
  127. +>0x0A beshort 0x0FE0
  128. +>>0x0C belong 0xF110FFEE
  129. +>>>0x208 beshort 0x0100
  130. +>>>>0x020A byte 0x0F
  131. +>>>>>0x020C bequad 0x000000045F000000
  132. +>>>>>>0x5B byte 0x02
  133. +>>>>>>>0x54 belong x Nintendo amiibo NFC dump - amiibo ID: %08X-
  134. +>>>>>>>0x58 belong x \b%08X
  135. --- a/magic/Magdir/filesystems
  136. +++ b/magic/Magdir/filesystems
  137. @@ -1949,7 +1949,19 @@
  138. >0 use cdrom
  139. # .cso files
  140. -0 string CISO Compressed ISO CD image
  141. +# Reference: http://pismotec.com/ciso/ciso.h
  142. +# NOTE: There are two other formats with the same magic but
  143. +# completely incompatible specifications:
  144. +# - GameCube/Wii CISO: https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/DiscIO/CISOBlob.h
  145. +# - PSP CISO: https://github.com/jamie/ciso/blob/master/ciso.h
  146. +0 string CISO
  147. +# Other fields are used to determine what type of CISO this is:
  148. +# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size)
  149. +# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size)
  150. +# - None of the above: Compact ISO.
  151. +>4 lelong !0
  152. +>>4 lelong !0x200000
  153. +>>>0x10 lelong !0x800 Compressed ISO CD image
  154. # cramfs filesystem - russell@coker.com.au
  155. 0 lelong 0x28cd3d45 Linux Compressed ROM File System data, little endian
  156. --- a/magic/Magdir/fonts
  157. +++ b/magic/Magdir/fonts
  158. @@ -100,9 +100,11 @@
  159. # X11 fonts, from Daniel Quinlan (quinlan@yggdrasil.com)
  160. # PCF must come before SGI additions ("MIPSEL MIPS-II COFF" collides)
  161. -0 string \001fcp X11 Portable Compiled Font data
  162. ->12 byte 0x02 \b, LSB first
  163. ->12 byte 0x0a \b, MSB first
  164. +0 string \001fcp X11 Portable Compiled Font data,
  165. +>12 lelong ^0x08 bit: LSB,
  166. +>12 lelong &0x08 bit: MSB,
  167. +>12 lelong ^0x04 byte: LSB first
  168. +>12 lelong &0x04 byte: MSB first
  169. 0 string D1.0\015 X11 Speedo font data
  170. #------------------------------------------------------------------------------
  171. --- /dev/null
  172. +++ b/magic/Magdir/gpu
  173. @@ -0,0 +1,16 @@
  174. +
  175. +#------------------------------------------------------------------------------
  176. +# $File: images,v 1.118 2016/11/08 02:58:21 christos Exp $
  177. +# gpu: file(1) magic for GPU input files
  178. +
  179. +# Standard Portable Intermediate Representation (SPIR)
  180. +# Documentation: https://www.khronos.org/spir
  181. +# Typical file extension: .spv
  182. +
  183. +0 belong 0x07230203 Khronos SPIR-V binary, big-endian
  184. +>4 belong x \b, version 0x%08x
  185. +>8 belong x \b, generator 0x%08x
  186. +
  187. +0 lelong 0x07230203 Khronos SPIR-V binary, little-endian
  188. +>4 lelong x \b, version 0x%08x
  189. +>8 lelong x \b, generator 0x%08x
  190. --- a/magic/Magdir/icc
  191. +++ b/magic/Magdir/icc
  192. @@ -11,41 +11,204 @@
  193. # http://www.color.org/specification/ICC1v43_2010-12.pdf
  194. #
  195. # for Specification ICC.1:2010 (Profile version 4.3.0.0).
  196. +# URL: http://fileformats.archiveteam.org/wiki/ICC_profile
  197. +# Reference: http://www.color.org/iccmax/ICC.2-2016-7.pdf
  198. +# Update: Joerg Jenderek
  199. #
  200. # Bytes 36 to 39 contain a generic profile file signature of "acsp";
  201. # bytes 40 to 43 "may be used to identify the primary platform/operating
  202. # system framework for which the profile was created".
  203. #
  204. -# There are other fields that might be worth dumping as well.
  205. -#
  206. +# check and display ICC/ICM color profile
  207. +0 name color-profile
  208. +>36 string acsp
  209. +# skip ASCII like Cognacspirit.txt by month <= 12
  210. +>>26 ubeshort <13
  211. +# platform/operating system. Only 5 mentioned
  212. +#
  213. # This appears to be what's used for Apple ColorSync profiles.
  214. # Instead of adding that, Apple just changed the generic "acsp" entry
  215. # to be for "ColorSync ICC Color Profile" rather than "Kodak Color
  216. # Management System, ICC Profile".
  217. # Yes, it's "APPL", not "AAPL"; see the spec.
  218. -36 string acspAPPL ColorSync ICC Profile
  219. -!:mime application/vnd.iccprofile
  220. +>>>40 string APPL ColorSync
  221. # Microsoft ICM color profile
  222. -36 string acspMSFT Microsoft ICM Color Profile
  223. -!:mime application/vnd.iccprofile
  224. +>>>40 string MSFT Microsoft
  225. # Yes, that's a blank after "SGI".
  226. -36 string acspSGI\ SGI ICC Profile
  227. -!:mime application/vnd.iccprofile
  228. +>>>40 string SGI\ SGI
  229. # XXX - is this what's used for the Sun KCMS or not? The standard file
  230. # uses just "acsp" for that, but Apple's file uses it for "ColorSync",
  231. # and there *is* an identified "primary platform" value of SUNW.
  232. -36 string acspSUNW Sun KCMS ICC Profile
  233. +>>>40 string SUNW Sun KCMS
  234. +
  235. +# 5th platform
  236. +>>>40 string TGNT Taligent
  237. +
  238. +# remaing "l" "e" of "color profile" printed later to avoid error
  239. +>>>40 string x color profi
  240. +#>>>40 string x (%.4s)
  241. !:mime application/vnd.iccprofile
  242. +# for "ICM" extension only versions 2.x and for Kodak "CC" 2.0 is found
  243. +>>>8 ubyte =2
  244. +# do not use empty message text to a avoid error like
  245. +# icc, 82: Warning: Current entry does not yet have a description for adding a EXTENSION type
  246. +# file.exe: could not find any valid magic files!
  247. +>>>>9 ubyte !0 \ble
  248. +!:ext icc/icm
  249. +# minor version
  250. +>>>>9 ubyte =0 \bl
  251. +# Kodak colour management system
  252. +>>>>>4 string =KCMS \be
  253. +!:ext icc/icm/cc
  254. +>>>>>4 string !KCMS \be
  255. +!:ext icc/icm
  256. +>>>8 ubyte !2 \ble
  257. +!:ext icc
  258. +# Profile version major.4bit-minor.sub1.sub2 like 4.3.0.0 (04300000h)
  259. +>>>8 ubyte x %u
  260. +>>>9 ubyte/16 x \b.%u
  261. +# reserved and shall be null but 205.205 in umx1220u.icm
  262. +>>>10 ubyte >0 \b.%u
  263. +>>>>11 ubyte >0 \b.%u
  264. +# preferred colour management module like appl CCMS KCMS Lino UCCM "Win " "FF "
  265. +# skip space like in brmsl08f.icm and null like in brmsl09f.icm, brmsl07f.icm
  266. +>>>4 string >\ \b, type %.2s
  267. +>>>>6 string >\ \b%.1s
  268. +>>>>>7 string >\ \b%.1s
  269. +# colour space "XYZ " "Lab " "RGB " CMYK GRAY ...
  270. +>>>16 string x \b, %.3s
  271. +>>>19 string >\ \b%.1s
  272. +# Profile Connection Space (PCS) field usually "XYZ " or "Lab " but sometimes
  273. +# null or CMYK like in ISOcoated_v2_to_PSOcoated_v3_DeviceLink.icc
  274. +>>>20 string >\0 \b/%.3s
  275. +>>>>23 string >\ \b%.1s
  276. +# eleven device classes
  277. +>>>12 string x \b-%.4s device
  278. +# skip 00001964h in hpf69000.icc or 0h in XRDC50Q.ICM or " ROT" in brmsl05f.icm
  279. +>>>52 string >\
  280. +# skip "none" model like in "Trinitron Compatible 9300K G2.2.icm"
  281. +>>>>52 ubelong !0x6e6f6e65
  282. +# device manufacturer field like "HP " "IBM " EPSO
  283. +>>>>>48 string x \b, %.2s
  284. +>>>>>50 string >\ \b%.1s
  285. +>>>>>51 string >\ \b%.1s
  286. +# model like "ADI " "A265" and skip 20000404h in IS330.icm for RICOH RUSSIAN-SC
  287. +>>>>>52 string >\ \ \b/%.3s
  288. +>>>>>>55 string >\ \b%.1s
  289. +>>>>>52 string x model
  290. +# creator (often same as manufacture) like HP SONY XROX or null like in A925A.icm
  291. +>>>80 string >\0 by %.2s
  292. +>>>>82 string >\ \b%.1s
  293. +>>>>>83 string >\ \b%.1s
  294. +# profile size
  295. +>>>0 ubelong x \b, %u bytes
  296. +# skip invalid date 0 like in linearSRGB.icc
  297. +>>>24 ubequad !0
  298. +# datetime dd-mm-yyyy hh:mm:ss
  299. +>>>>28 ubeshort x \b, %u
  300. +# month <= 12
  301. +>>>>26 ubeshort x \b-%u
  302. +# year
  303. +>>>>24 ubeshort x \b-%u
  304. +# do not display midnight time like in CNHP8308.ICC
  305. +>>>>30 ubequad&0xFFffFFffFFff0000 !0
  306. +# hour <= 24
  307. +>>>>>30 ubeshort x %u
  308. +# minutes <= 59
  309. +>>>>>32 ubeshort x \b:%.2u
  310. +# seconds <= 59
  311. +>>>>>34 ubeshort x \b:%.2u
  312. +# vendor specific flags like 2 in HPCLJ5.ICM
  313. +>>>44 ubeshort >0 \b, 0x%x vendor flags
  314. +# profile flags bits 0-2 of least 16 used by ICC
  315. +#>>>44 ubelong >0 \b, 0x%x flags
  316. +# icEmbeddedProfileTrue
  317. +>>>44 ubelong &1 \b, embedded
  318. +# icEmbeddedProfileFalse
  319. +#>>>44 ubelong ^1 \b, not embedded
  320. +# icUseWithEmbeddedDataOnly
  321. +>>>44 ubelong &2 \b, dependently
  322. +# icUseAnywhere
  323. +#>>>44 ubelong ^2 \b, independently
  324. +>>>44 ubelong &4 \b, MCS
  325. +#>>>44 ubelong ^4 \b, no MCS
  326. +# vendor specific device attributes 1~srgb.icc
  327. +# E000D00h~CNB7QEDA.ICM C000A00h~CNB5FCAA.ICM 01040401h~CNB25PE3.ICM
  328. +>>>56 ubelong >0 \b, 0x%x vendor attribute
  329. +# ICC device attributes bits 0-7 used
  330. +#>>>60 ubelong x \b, 0x%x attribute
  331. +# http://www.color.org/icc34.h
  332. +>>>60 ubelong &0x01 \b, transparent
  333. +#>>>60 ubelong ^0x01 \b, reflective
  334. +>>>60 ubelong &0x02 \b, matte
  335. +#>>>60 ubelong ^0x02 \b, glossy
  336. +>>>60 ubelong &0x04 \b, negative
  337. +#>>>60 ubelong ^0x04 \b, positive
  338. +>>>60 ubelong &0x08 \b, black&white
  339. +#>>>60 ubelong ^0x08 \b, colour
  340. +>>>60 ubelong &0x10 \b, non-paper
  341. +#>>>60 ubelong ^0x10 \b, paper
  342. +>>>60 ubelong &0x20 \b, non-textured
  343. +#>>>60 ubelong ^0x20 \b, textured
  344. +>>>60 ubelong &0x40 \b, non-isotropic
  345. +#>>>60 ubelong ^0x40 \b, isotropic
  346. +>>>60 ubelong &0x80 \b, self-luminous
  347. +#>>>60 ubelong ^0x80 \b, non-self-luminous
  348. +# rendering intent 0-3 but 7AEA5027h in EE051__1.ICM 6CB1BCh in EE061__1.ICM
  349. +>>>64 ubelong >3 \b, 0x%x rendering intent
  350. +#>>>64 ubelong =0 \b, perceptual
  351. +>>>64 ubelong =1 \b, relative colorimetric
  352. +>>>64 ubelong =2 \b, saturation
  353. +>>>64 ubelong =3 \b, absolute colorimetric
  354. +# PCS illuminant (3*s15Fixed16Numbers) often 0000f6d6 00010000 0000d32d
  355. +>>>71 ubequad !0xd6000100000000d3 \b, PCS
  356. +# usually X~0.9642*65536=63189.8112~63190=F6D5h ; but also found
  357. +# often F6D6 in gt5000r.icm, F6B8 in kodakce.icm, F6CA in RSWOP.icm
  358. +>>>>68 ubelong !0x0000f6d5 X=0x%x
  359. +# usually Y=1.0~00010000h but Y=0 in brmsl07f.icm
  360. +>>>>72 ubelong !0x00010000 Y=0x%x
  361. +# usually Z~0.8249*65536=54060.6464~54061=D32Dh ; but also found
  362. +# D2F7 in hp1200c.icm, often D32C in A925A.icm, D309 in RSWOP.icm , D2F8 in kodak_dc.icm
  363. +>>>>76 ubelong !0x0000d32d Z=0x%x
  364. +# Profile ID. MD5 fingerprinting method as defined in Internet RFC 1321.
  365. +>>>84 ubequad >0 \b, 0x%llx MD5
  366. +# reserved in older versions should be zero but also found CDCDCDCDCDCDCDCD
  367. +#>>100 ubequad x \b 0x%llx reserved
  368. +# tag table
  369. +# 6 <= tags count <= 43
  370. +#>>>128 ubelong >43 \b, %u tags
  371. +>>>128 ubelong x
  372. +# shall contain the profileDescriptionTag "desc" , copyrightTag "cprt"
  373. +# search range = tags count * 12 -8=< maximal tag count * 12 -8= 43 * 12 -8= 508
  374. +>>>>132 search/508 cprt
  375. +# but no copyright tag in linearSRGB.icc
  376. +# beneath /System/Library/Frameworks/WebKit.framework/
  377. +# Versions/A/Frameworks/WebCore.framework/Versions/A/Resources
  378. +>>>>132 default x \b, no copyright tag
  379. +# 1st tag
  380. +#>>>132 string x \b, 1st tag %.4s
  381. +#>>>136 ubelong x 0x%x offset
  382. +#>>>140 ubelong x 0x%x len
  383. +# 2nd tag,...
  384. +# look also for profileDescriptionTag "desc"
  385. +>>>132 search/508 desc
  386. +# look further for TextDescriptionType "desc" signature
  387. +>>>>(&0.L) string =desc
  388. +>>>>>&4 pstring/l x "%s"
  389. +# look alternative for multiLocalizedUnicodeType "mluc" signature like in VideoPAL.icc
  390. +>>>>(&0.L) string =mluc
  391. +>>>>>&(&8.L) ubequad x
  392. +>>>>>>&4 bestring16 x '%s'
  393. # Any other profile.
  394. # XXX - should we use "acsp\0\0\0\0" for "no primary platform" profiles,
  395. # and use "acsp" for everything else and dump the "primary platform"
  396. # string in those cases?
  397. -36 string acsp ICC Profile
  398. -!:mime application/vnd.iccprofile
  399. +36 string acsp
  400. +>0 use color-profile
  401. --- a/magic/Magdir/images
  402. +++ b/magic/Magdir/images
  403. @@ -41,7 +41,11 @@
  404. >>>>>>3 uleshort 0
  405. >>>>>>>0 use tga-image
  406. # Color Map
  407. ->>>>>1 ubyte >0
  408. +>>>>>1 belong&0xfff7ffff 0x01010000
  409. +>>>>>>0 use tga-image
  410. +>>>>>1 belong&0xfff7ffff 0x00020000
  411. +>>>>>>0 use tga-image
  412. +>>>>>1 belong&0xfff7ffff 0x00030000
  413. >>>>>>0 use tga-image
  414. # display tga bitmap image information
  415. 0 name tga-image
  416. @@ -418,6 +422,7 @@
  417. #
  418. 0 string \x89PNG\x0d\x0a\x1a\x0a PNG image data
  419. !:mime image/png
  420. +!:strength +10
  421. >16 belong x \b, %d x
  422. >20 belong x %d,
  423. >24 byte x %d-bit
  424. @@ -1451,3 +1456,12 @@
  425. >0x10 string GVRT Sega GVR image:
  426. >>0x10 use sega-gvr-image-header
  427. >>0x08 belong x \b, global index = %u
  428. +
  429. +# Light Field Picture
  430. +# Documentation: http://optics.miloush.net/lytro/TheFileFormat.aspx
  431. +# Typical file extensions: .lfp .lfr .lfx
  432. +
  433. +0 belong 0x894C4650
  434. +>4 belong 0x0D0A1A0A
  435. +>12 belong 0x00000000 Lytro Light Field Picture
  436. +>8 belong x \b, version %d
  437. --- a/magic/Magdir/make
  438. +++ b/magic/Magdir/make
  439. @@ -2,6 +2,7 @@
  440. # $File: make,v 1.2 2015/08/25 07:34:06 christos Exp $
  441. # make: file(1) magic for makefiles
  442. #
  443. +# URL: https://en.wikipedia.org/wiki/Make_(software)
  444. 0 regex/100l \^CFLAGS makefile script text
  445. !:mime text/x-makefile
  446. 0 regex/100l \^VPATH makefile script text
  447. @@ -10,12 +11,19 @@
  448. !:mime text/x-makefile
  449. 0 regex/100l \^all: makefile script text
  450. !:mime text/x-makefile
  451. -0 regex/100l \^\.PRECIOUS makefile script text
  452. +0 regex/100l \^\\.PRECIOUS makefile script text
  453. !:mime text/x-makefile
  454. -0 regex/100l \^\.BEGIN BSD makefile script text
  455. +# Update: Joerg Jenderek
  456. +# Reference: https://www.freebsd.org/cgi/man.cgi?make(1)
  457. +# exclude grub-core\lib\libgcrypt\mpi\Makefile.am with "#BEGIN_ASM_LIST"
  458. +# by additional escaping point character
  459. +0 regex/100l \^\\.BEGIN BSD makefile script text with "%s"
  460. +!:mime text/x-makefile
  461. +!:ext /mk
  462. +# exclude MS Windows help file CoNtenT with ":include FOOBAR.CNT"
  463. +# and NSIS script with "!include" by additional escaping point character
  464. +0 regex/100l \^\\.include BSD makefile script text with "%s"
  465. !:mime text/x-makefile
  466. -0 regex/100l \^\.include BSD makefile script text
  467. -!:mime text/x-makefile
  468. -
  469. +!:ext /mk
  470. 0 regex/100l \^SUBDIRS automake makefile script text
  471. !:mime text/x-makefile
  472. --- a/magic/Magdir/msdos
  473. +++ b/magic/Magdir/msdos
  474. @@ -565,10 +565,23 @@
  475. 0 string/b PO^Q` Microsoft Word 6.0 Document
  476. !:mime application/msword
  477. #
  478. -0 string/b \376\067\0\043 Microsoft Office Document
  479. +4 long 0
  480. +>0 belong 0xfe320000 Microsoft Word for Macintosh 1.0
  481. !:mime application/msword
  482. -0 string/b \333\245-\0\0\0 Microsoft Office Document
  483. +!:ext mcw
  484. +>0 belong 0xfe340000 Microsoft Word for Macintosh 3.0
  485. !:mime application/msword
  486. +!:ext mcw
  487. +>0 belong 0xfe37001c Microsoft Word for Macintosh 4.0
  488. +!:mime application/msword
  489. +!:ext mcw
  490. +>0 belong 0xfe370023 Microsoft Word for Macintosh 5.0
  491. +!:mime application/msword
  492. +!:ext mcw
  493. +
  494. +0 string/b \333\245-\0\0\0 Microsoft Word 2.0 Document
  495. +!:mime application/msword
  496. +!:ext doc
  497. 512 string/b \354\245\301 Microsoft Word Document
  498. !:mime application/msword
  499. @@ -1106,3 +1119,40 @@
  500. 0 string MIOPEN Mallard BASIC Jetsam data
  501. 0 string Jetsam0 Mallard BASIC Jetsam index data
  502. +# DOS backup 2.0 to 3.2
  503. +
  504. +# backupid.@@@
  505. +
  506. +# plausibility check for date
  507. +0x3 ushort >1979
  508. +>0x5 ubyte-1 <31
  509. +>>0x6 ubyte-1 <12
  510. +# actually 121 nul bytes
  511. +>>>0x7 string \0\0\0\0\0\0\0\0
  512. +>>>>0x1 ubyte x DOS 2.0 backup id file, sequence %d
  513. +!:ext @@@
  514. +>>>>0x0 ubyte 0xff \b, last disk
  515. +
  516. +# backed up file
  517. +
  518. +# plausibility check for file name length
  519. +0x53 ubyte-1 <80
  520. +# actually 54 nul bytes
  521. +>0x54 string \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
  522. +>>0x5 string x DOS 2.0 backed up file %s,
  523. +>>0 ubyte 0xff complete file
  524. +>>0 ubyte !0xff
  525. +>>>1 ushort x split file, sequence %d
  526. +
  527. +
  528. +# DOS backup 3.3 to 5.x
  529. +
  530. +# CONTROL.nnn files
  531. +0 string \x8bBACKUP\x20
  532. +# actually 128 nul bytes
  533. +>0xa string \0\0\0\0\0\0\0\0
  534. +>>0x9 ubyte x DOS 3.3 backup control file, sequence %d
  535. +>>0x8a ubyte 0xff \b, last disk
  536. +
  537. +# NB: The BACKUP.nnn files consist of the files backed up,
  538. +# concatenated.
  539. --- a/magic/Magdir/msx
  540. +++ b/magic/Magdir/msx
  541. @@ -245,18 +245,18 @@
  542. 0x4000 string/b AB
  543. >0x4002 uleshort >0x400F
  544. >>0x400A string \0\0\0\0\0\0 MSX ROM with nonstandard page order
  545. ->>0x4002 uleshort x \b, init=0x%04x
  546. ->>0x4004 uleshort >0 \b, stahdl=0x%04x
  547. ->>0x4006 uleshort >0 \b, devhdl=0x%04x
  548. ->>0x4008 uleshort >0 \b, bas=0x%04x
  549. +>>>0x4002 uleshort x \b, init=0x%04x
  550. +>>>0x4004 uleshort >0 \b, stahdl=0x%04x
  551. +>>>0x4006 uleshort >0 \b, devhdl=0x%04x
  552. +>>>0x4008 uleshort >0 \b, bas=0x%04x
  553. 0x8000 string/b AB
  554. >0x8002 uleshort >0x400F
  555. >>0x800A string \0\0\0\0\0\0 MSX ROM with nonstandard page order
  556. ->>0x8002 uleshort x \b, init=0x%04x
  557. ->>0x8004 uleshort >0 \b, stahdl=0x%04x
  558. ->>0x8006 uleshort >0 \b, devhdl=0x%04x
  559. ->>0x8008 uleshort >0 \b, bas=0x%04x
  560. +>>>0x8002 uleshort x \b, init=0x%04x
  561. +>>>0x8004 uleshort >0 \b, stahdl=0x%04x
  562. +>>>0x8006 uleshort >0 \b, devhdl=0x%04x
  563. +>>>0x8008 uleshort >0 \b, bas=0x%04x
  564. 0x3C000 string/b AB
  565. --- a/magic/Magdir/sgml
  566. +++ b/magic/Magdir/sgml
  567. @@ -46,6 +46,12 @@
  568. !:mime text/html
  569. !:strength + 5
  570. +# SVG document
  571. +# https://www.w3.org/TR/SVG/single-page.html
  572. +0 search/4096/cWbt \<!doctype\ svg SVG XML document
  573. +!:mime image/svg+xml
  574. +!:strength + 5
  575. +
  576. 0 search/4096/cwt \<head\> HTML document text
  577. !:mime text/html
  578. !:strength + 5
  579. --- /dev/null
  580. +++ b/magic/Magdir/yara
  581. @@ -0,0 +1,17 @@
  582. +
  583. +
  584. +#------------------------------------------------------------------------------
  585. +# $File: map,v 1.4 2015/08/10 05:18:27 christos Exp $
  586. +# yara: file(1) magic for http://virustotal.github.io/yara/
  587. +#
  588. +
  589. +0 string YARA
  590. +>4 lelong >2047
  591. +>8 byte <20 YARA 3.x compiled rule set
  592. +# version
  593. +>>8 clear
  594. +>>8 byte 6 created with version 3.3.0
  595. +>>8 byte 8 created with version 3.4.0
  596. +>>8 byte 11 created with version 3.5.0
  597. +>>8 default x
  598. +>>>8 byte x development version 0x%02x
  599. --- a/magic/Makefile.am
  600. +++ b/magic/Makefile.am
  601. @@ -104,6 +104,7 @@
  602. $(MAGIC_FRAGMENT_DIR)/gnu \
  603. $(MAGIC_FRAGMENT_DIR)/gnumeric \
  604. $(MAGIC_FRAGMENT_DIR)/gpt \
  605. +$(MAGIC_FRAGMENT_DIR)/gpu \
  606. $(MAGIC_FRAGMENT_DIR)/grace \
  607. $(MAGIC_FRAGMENT_DIR)/graphviz \
  608. $(MAGIC_FRAGMENT_DIR)/gringotts \
  609. @@ -285,6 +286,7 @@
  610. $(MAGIC_FRAGMENT_DIR)/xilinx \
  611. $(MAGIC_FRAGMENT_DIR)/xo65 \
  612. $(MAGIC_FRAGMENT_DIR)/xwindows \
  613. +$(MAGIC_FRAGMENT_DIR)/yara \
  614. $(MAGIC_FRAGMENT_DIR)/zfs \
  615. $(MAGIC_FRAGMENT_DIR)/zilog \
  616. $(MAGIC_FRAGMENT_DIR)/zyxel
  617. --- a/src/apprentice.c
  618. +++ b/src/apprentice.c
  619. @@ -2291,7 +2291,7 @@
  620. return parse_extra(ms, me, line,
  621. CAST(off_t, offsetof(struct magic, ext)),
  622. - sizeof(m->ext), "EXTENSION", ",!+-/", 0);
  623. + sizeof(m->ext), "EXTENSION", ",!+-/@", 0);
  624. }
  625. /*
  626. --- a/src/cdf.c
  627. +++ b/src/cdf.c
  628. @@ -530,6 +530,9 @@
  629. scn->sst_dirlen = len;
  630. scn->sst_ss = ss;
  631. + if (sid == CDF_SECID_END_OF_CHAIN || len == 0)
  632. + return cdf_zero_stream(scn);
  633. +
  634. if (scn->sst_len == (size_t)-1)
  635. goto out;
  636. --- a/src/der.c
  637. +++ b/src/der.c
  638. @@ -159,31 +159,49 @@
  639. return tag;
  640. }
  641. +/*
  642. + * Read the length of a DER tag from the input.
  643. + *
  644. + * `c` is the input, `p` is an output parameter that specifies how much of the
  645. + * input we consumed, and `l` is the maximum input length.
  646. + *
  647. + * Returns the length, or DER_BAD if the end of the input is reached or the
  648. + * length exceeds the remaining input.
  649. + */
  650. static uint32_t
  651. getlength(const uint8_t *c, size_t *p, size_t l)
  652. {
  653. uint8_t digits, i;
  654. size_t len;
  655. + int is_onebyte_result;
  656. if (*p >= l)
  657. return DER_BAD;
  658. - digits = c[(*p)++];
  659. + /*
  660. + * Digits can either be 0b0 followed by the result, or 0b1
  661. + * followed by the number of digits of the result. In either case,
  662. + * we verify that we can read so many bytes from the input.
  663. + */
  664. + is_onebyte_result = (c[*p] & 0x80) == 0;
  665. + digits = c[(*p)++] & 0x7f;
  666. + if (*p + digits >= l)
  667. + return DER_BAD;
  668. - if ((digits & 0x80) == 0)
  669. + if (is_onebyte_result)
  670. return digits;
  671. - digits &= 0x7f;
  672. + /*
  673. + * Decode len. We've already verified that we're allowed to read
  674. + * `digits` bytes.
  675. + */
  676. len = 0;
  677. -
  678. - if (*p + digits >= l)
  679. - return DER_BAD;
  680. -
  681. for (i = 0; i < digits; i++)
  682. len = (len << 8) | c[(*p)++];
  683. +
  684. if (*p + len >= l)
  685. return DER_BAD;
  686. - return len;
  687. + return len;
  688. }
  689. static const char *
  690. --- a/src/funcs.c
  691. +++ b/src/funcs.c
  692. @@ -76,7 +76,7 @@
  693. ms->o.buf = buf;
  694. return 0;
  695. out:
  696. - file_error(ms, errno, "vasprintf failed");
  697. + fprintf(stderr, "vasprintf failed (%s)", strerror(errno));
  698. return -1;
  699. }