From 41a2f7074dabe6e702d4ce300c86894bfae1d4b1 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 6 Dec 2014 20:51:00 +0100 Subject: [PATCH] Fixed bug #68398 msooxml matches too many archives --- NEWS | 3 +++ ext/fileinfo/data_file.c | 8 ++++---- ext/fileinfo/magicdata.patch | 25 +++++++++++++++++++++++++ ext/fileinfo/tests/68398.zip | Bin 0 -> 356 bytes ext/fileinfo/tests/bug68398.phpt | 15 +++++++++++++++ 5 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 ext/fileinfo/tests/68398.zip create mode 100644 ext/fileinfo/tests/bug68398.phpt diff --git a/NEWS b/NEWS index b499ca5986..c4999e48f0 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,9 @@ PHP NEWS . Implemented FR #68268 (DatePeriod: Getter for start date, end date and interval). (Marc Bennewitz) +- Fileinfo: + . Fixed bug #68398 (msooxml matches too many archives). (Anatol) + - mbstring: . Fixed bug #68504 (--with-libmbfl configure option not present on Windows). (Ashesh Vashi) diff --git a/ext/fileinfo/data_file.c b/ext/fileinfo/data_file.c index 5b24670a72..813b57d725 100644 --- a/ext/fileinfo/data_file.c +++ b/ext/fileinfo/data_file.c @@ -48144,11 +48144,11 @@ const unsigned char php_magic_database[2803888] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x3D, 0x1F, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, +0x01, 0x00, 0x00, 0x00, 0x3D, 0x23, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x5B, 0x43, 0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x5F, 0x54, 0x79, 0x70, 0x65, 0x73, 0x5D, 0x2E, -0x78, 0x6D, 0x6C, 0x7C, 0x5F, 0x72, 0x65, 0x6C, 0x73, 0x2F, 0x2E, 0x72, 0x65, 0x6C, 0x73, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x5C, 0x5B, 0x43, 0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x5F, 0x54, 0x79, 0x70, 0x65, 0x73, 0x5C, +0x5D, 0x5C, 0x2E, 0x78, 0x6D, 0x6C, 0x7C, 0x5F, 0x72, 0x65, 0x6C, 0x73, 0x2F, 0x5C, 0x2E, 0x72, +0x65, 0x6C, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/ext/fileinfo/magicdata.patch b/ext/fileinfo/magicdata.patch index 524d40b567..3f593f72ae 100644 --- a/ext/fileinfo/magicdata.patch +++ b/ext/fileinfo/magicdata.patch @@ -56,3 +56,28 @@ index 26b2869..bcd0f43 100644 -- 2.0.3 +From 71d04468a5777fe43064af02f06d74cb60feafab Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andreas=20K=C3=B6hler?= +Date: Sat, 14 Jun 2014 03:04:28 +0200 +Subject: [PATCH] Fix regex in msooxml to avoid matching other archives. + +--- + magic/Magdir/msooxml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/magic/Magdir/msooxml b/magic/Magdir/msooxml +index c908b71..5ff3760 100644 +--- a/magic/Magdir/msooxml ++++ b/magic/Magdir/msooxml +@@ -16,7 +16,7 @@ + 0 string PK\003\004 + !:strength +10 + # make sure the first file is correct +->0x1E regex \[Content_Types\]\.xml|_rels/\.rels ++>0x1E regex \\[Content_Types\\]\\.xml|_rels/\\.rels + # 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 +-- +2.0.0 + diff --git a/ext/fileinfo/tests/68398.zip b/ext/fileinfo/tests/68398.zip new file mode 100644 index 0000000000000000000000000000000000000000..2d0204977b21a20e0b9b8b0a7257da66a9f631d7 GIT binary patch literal 356 zcmWIWW@Zs#W&na83g=uvGz>5S87cY!KzS~#@*u$!eIr5&jBzVq2bJ3&lkOT`59tYCxAPxfn8we_; literal 0 HcmV?d00001 diff --git a/ext/fileinfo/tests/bug68398.phpt b/ext/fileinfo/tests/bug68398.phpt new file mode 100644 index 0000000000..78d3b8929f --- /dev/null +++ b/ext/fileinfo/tests/bug68398.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #68398: msooxml matches too many archives +--SKIPIF-- + +--FILE-- +file(dirname(__FILE__) . DIRECTORY_SEPARATOR . '68398.zip')); +?> ++++DONE+++ +--EXPECTF-- +string(31) "application/zip; charset=binary" ++++DONE+++ + -- 2.40.0