Skip to content

Commit

Permalink
fileinfo: Backport xz detection fix
Browse files Browse the repository at this point in the history
Upstream: file/file@9b0459a

Fixes: #11298

Signed-off-by: Anatol Belski <ab@php.net>
  • Loading branch information
weltling committed Jul 1, 2023
1 parent 07dd0c8 commit 86f79b2
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 107 deletions.
150 changes: 75 additions & 75 deletions ext/fileinfo/data_file.c

Large diffs are not rendered by default.

75 changes: 51 additions & 24 deletions ext/fileinfo/magicdata.patch
@@ -1,53 +1,80 @@
diff -ur Magdir.orig/fonts Magdir/fonts
--- Magdir.orig/fonts 2021-02-23 01:49:24.000000000 +0100
+++ Magdir/fonts 2022-09-18 14:07:14.233023271 +0200
@@ -384,11 +384,13 @@
diff -ur Magdir/compress Magdir.orig/compress
--- Magdir/compress 2023-07-01 16:33:17.323889842 +0200
+++ Magdir.orig/compress 2021-03-31 01:47:28.000000000 +0200
@@ -1,5 +1,5 @@
#------------------------------------------------------------------------------
-# $File: compress,v 1.81 2021/04/19 17:01:45 christos Exp $
+# $File: compress,v 1.80 2021/03/15 17:49:24 christos Exp $
# compress: file(1) magic for pure-compression formats (no archives)
#
# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
@@ -265,13 +265,14 @@

# http://tukaani.org/xz/xz-file-format.txt
0 ustring \xFD7zXZ\x00 XZ compressed data, checksum
-!:strength * 2
-!:mime application/x-xz
>7 byte&0xf 0x0 NONE
>7 byte&0xf 0x1 CRC32
>7 byte&0xf 0x4 CRC64
>7 byte&0xf 0xa SHA-256

+!:strength * 2
+!:mime application/x-xz
+
# https://github.com/ckolivas/lrzip/blob/master/doc/magic.header.txt
0 string LRZI LRZIP compressed data
>4 byte x - version %d
diff -ur Magdir/fonts Magdir.orig/fonts
--- Magdir/fonts 2023-07-01 16:32:41.731654699 +0200
+++ Magdir.orig/fonts 2021-02-23 01:49:24.000000000 +0100
@@ -384,13 +384,11 @@

# https://www.w3.org/TR/WOFF/
0 string wOFF Web Open Font Format
+!:mime font/woff
-!:mime font/woff
>0 use woff
>20 beshort x \b, version %d
>22 beshort x \b.%d
# https://www.w3.org/TR/WOFF2/
0 string wOF2 Web Open Font Format (Version 2)
+!:mime font/woff2
-!:mime font/woff2
>0 use woff
#>20 belong x \b, totalCompressedSize %d
>24 beshort x \b, version %d
diff -ur Magdir.orig/mail.news Magdir/mail.news
--- Magdir.orig/mail.news 2021-03-31 01:47:28.000000000 +0200
+++ Magdir/mail.news 2021-04-05 19:41:55.168556972 +0200
diff -ur Magdir/mail.news Magdir.orig/mail.news
--- Magdir/mail.news 2023-07-01 16:32:41.731654699 +0200
+++ Magdir.orig/mail.news 2021-03-31 01:47:28.000000000 +0200
@@ -1,5 +1,5 @@
#------------------------------------------------------------------------------
-# $File: mail.news,v 1.26 2021/03/21 14:37:03 christos Exp $
+# $File: mail.news,v 1.27 2021/04/05 16:36:14 christos Exp $
-# $File: mail.news,v 1.27 2021/04/05 16:36:14 christos Exp $
+# $File: mail.news,v 1.26 2021/03/21 14:37:03 christos Exp $
# mail.news: file(1) magic for mail and news
#
# Unfortunately, saved netnews also has From line added in some news software.
@@ -81,4 +81,4 @@
# File format spec: https://wiki.dovecot.org/Design/Dcrypt/#File_format
# From: Stephen Gildea
0 string CRYPTED\003\007 Dovecot encrypted message
->9 byte xu \b, dcrypt version %d
+>9 byte x \b, dcrypt version %d
diff -ur Magdir.orig/rpm Magdir/rpm
--- Magdir.orig/rpm 2021-02-23 01:49:24.000000000 +0100
+++ Magdir/rpm 2021-04-05 19:40:55.080911893 +0200
@@ -29,6 +29,7 @@
->9 byte x \b, dcrypt version %d
+>9 byte xu \b, dcrypt version %d
diff -ur Magdir/rpm Magdir.orig/rpm
--- Magdir/rpm 2023-07-01 16:32:41.731654699 +0200
+++ Magdir.orig/rpm 2021-02-23 01:49:24.000000000 +0100
@@ -29,7 +29,6 @@
>>8 beshort 17 SuperH
>>8 beshort 18 Xtensa
>>8 beshort 255 noarch
+>>10 string x %s
->>10 string x %s

#delta RPM Daniel Novotny (dnovotny@redhat.com)
0 string drpm Delta RPM
diff -ur Magdir.orig/securitycerts Magdir/securitycerts
--- Magdir.orig/securitycerts 2021-02-23 01:49:24.000000000 +0100
+++ Magdir/securitycerts 2021-04-05 19:40:55.080911893 +0200
@@ -4,3 +4,5 @@
diff -ur Magdir/securitycerts Magdir.orig/securitycerts
--- Magdir/securitycerts 2023-07-01 16:32:41.731654699 +0200
+++ Magdir.orig/securitycerts 2021-02-23 01:49:24.000000000 +0100
@@ -4,5 +4,3 @@
0 search/1 -----BEGIN\ CERTIFICATE------ RFC1421 Security Certificate text
0 search/1 -----BEGIN\ NEW\ CERTIFICATE RFC1421 Security Certificate Signing Request text
0 belong 0xedfeedfe Sun 'jks' Java Keystore File data
+
+0 string \0volume_key volume_key escrow packet
-
-0 string \0volume_key volume_key escrow packet
2 changes: 2 additions & 0 deletions ext/fileinfo/tests/finfo_file_002.phpt
Expand Up @@ -45,4 +45,6 @@ array(%d) {
string(10) "video/webm"
["%s/resources/test.woff"]=>
string(9) "font/woff"
["%s/resources/test.xz"]=>
string(16) "application/x-xz"
}
7 changes: 3 additions & 4 deletions ext/fileinfo/tests/magic
Expand Up @@ -7439,7 +7439,7 @@
0 string msc Message Sequence Chart (chart)
0 string submsc Message Sequence Chart (subchart)
#------------------------------------------------------------------------------
# $File: compress,v 1.80 2021/03/15 17:49:24 christos Exp $
# $File: compress,v 1.81 2021/04/19 17:01:45 christos Exp $
# compress: file(1) magic for pure-compression formats (no archives)
#
# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
Expand Down Expand Up @@ -7705,14 +7705,13 @@

# http://tukaani.org/xz/xz-file-format.txt
0 ustring \xFD7zXZ\x00 XZ compressed data, checksum
!:strength * 2
!:mime application/x-xz
>7 byte&0xf 0x0 NONE
>7 byte&0xf 0x1 CRC32
>7 byte&0xf 0x4 CRC64
>7 byte&0xf 0xa SHA-256

!:strength * 2
!:mime application/x-xz

# https://github.com/ckolivas/lrzip/blob/master/doc/magic.header.txt
0 string LRZI LRZIP compressed data
>4 byte x - version %d
Expand Down
7 changes: 3 additions & 4 deletions ext/fileinfo/tests/magic私はガラスを食べられます
Expand Up @@ -7439,7 +7439,7 @@
0 string msc Message Sequence Chart (chart)
0 string submsc Message Sequence Chart (subchart)
#------------------------------------------------------------------------------
# $File: compress,v 1.80 2021/03/15 17:49:24 christos Exp $
# $File: compress,v 1.81 2021/04/19 17:01:45 christos Exp $
# compress: file(1) magic for pure-compression formats (no archives)
#
# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
Expand Down Expand Up @@ -7705,14 +7705,13 @@

# http://tukaani.org/xz/xz-file-format.txt
0 ustring \xFD7zXZ\x00 XZ compressed data, checksum
!:strength * 2
!:mime application/x-xz
>7 byte&0xf 0x0 NONE
>7 byte&0xf 0x1 CRC32
>7 byte&0xf 0x4 CRC64
>7 byte&0xf 0xa SHA-256

!:strength * 2
!:mime application/x-xz

# https://github.com/ckolivas/lrzip/blob/master/doc/magic.header.txt
0 string LRZI LRZIP compressed data
>4 byte x - version %d
Expand Down
Binary file added ext/fileinfo/tests/resources/test.xz
Binary file not shown.

0 comments on commit 86f79b2

Please sign in to comment.