[File] [PATCH] Recognize ZIP archives with extra data prepended

Michał Górny mgorny at gentoo.org
Sun Oct 2 11:42:30 UTC 2022


The ZIP format allows prepending arbitrary data to the ZIP file
(e.g. a SFX stub).  The archiver then recognizes the archive by looking
up the central directory at the end of ZIP archive.  Teach file(1)
to recognize it as well through the presence of end-of-central-directory
record.
---
 magic/Magdir/archive | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/magic/Magdir/archive b/magic/Magdir/archive
index 16778356..ca883887 100644
--- a/magic/Magdir/archive
+++ b/magic/Magdir/archive
@@ -1789,6 +1789,14 @@
 !:mime	application/zip
 !:ext zip/cbz
 
+# Recognize ZIP archives with prepended data by end-of-central-directory record
+# https://en.wikipedia.org/wiki/ZIP_(file_format)#End_of_central_directory_record_(EOCD)
+# by Michał Górny <mgorny at gentoo.org>
+-2	uleshort	0
+>&-22	string	PK\005\006	Zip archive, with extra data prepended
+!:mime	application/zip
+!:ext zip/cbz
+
 # ACE archive (from http://www.wotsit.org/download.asp?f=ace)
 # by Stefan `Sec` Zehl <sec at 42.org>
 7	string		**ACE**		ACE archive data
-- 
2.37.3



More information about the File mailing list