Commit graph

63 commits

Author SHA1 Message Date
Niels Dossche
37dbad8fcd Upgrade to file 5.46 2025-02-15 12:53:07 +01:00
Peter Kokot
d3901b8ca6
Sync PHP_FILEINFO_UNCOMPRESS #if/ifdef/defined (#14525)
This fixes few more -Wundef warnings in ext/fileinfo. The
PHP_FILEINFO_UNCOMPRESS seems to be present to be defined at some point
but is currently unused in all build systems. Leaving this intact for
now.

Follow up of GH-5526 (-Wundef)
2024-06-10 08:11:25 +02:00
Niels Dossche
b7c5813c98
Update libmagic to 5.45 (#13369)
* Update libmagic to 5.45

This also cleans up magicdata.patch: changes that are already in upstream file
were removed from that patch file.

There are five (expected) test output changes.
All these were also checked with the file command.

  - bug77961.phpt changes because there's now an early error-return in the
    `if (ts == FILE_BADSIZE) {` branch.
  - cve-2014-1943.phpt and cve-2014-1943-mb.phpt change because now the crafted
    data is recognised as a simh file.
  - bug71434.phpt now properly recognises it as a Python file.
  - ext/fileinfo/tests/finfo_file_basic.phpt more specific mime type.

* Adjust memory requirement for s390x fileinfo run

The larger database causes a higher memory usage.
Similar to 962c082a5b.

* [ci skip] NEWS
2024-02-13 21:11:57 +01:00
Anatol Belski
25bb817804 fileinfo: libmagic: Simplify libmagic patch
For the time being, the new args passing pre-compiled regex are cut out.
On the PHP side, PCRE patterns are cached and thus a duplicated
mechanism isn't necessary.

There might be still advantages to carry pre-compiled patterns for
libmagic separately, but reusing this mechanism needs a better
consideration, as it might require to retain from the PHP internal pattern
caching mechanism.

Signed-off-by: Anatol Belski <ab@php.net>
2022-10-02 03:02:47 +02:00
Anatol Belski
a3dd514d4d fileinfo: Introduce php_libmagic.* to simplify patch
Signed-off-by: Anatol Belski <ab@php.net>
2022-10-02 03:02:47 +02:00
Anatol Belski
a24727a5ca fileinfo: libmagic: Apply libmagic.patch
Signed-off-by: Anatol Belski <ab@php.net>
2022-10-02 03:02:46 +02:00
Anatol Belski
6219d7fbc6 fileinfo: libmagic: Check in unpatched 5.43
Signed-off-by: Anatol Belski <ab@php.net>
2022-10-02 03:02:46 +02:00
Anatol Belski
f60dc3bd34 fileinfo: More VS compat
Signed-off-by: Anatol Belski <ab@php.net>
2021-04-05 21:23:26 +02:00
Anatol Belski
3b9173dc8f fileinfo: Port libmagic 5.40
Signed-off-by: Anatol Belski <ab@php.net>
2021-04-05 20:19:07 +02:00
Anatol Belski
bf93f1d824 fileinfo: Followup fixes
Signed-off-by: Anatol Belski <ab@php.net>
2020-08-29 19:03:41 +02:00
Anatol Belski
c3eeab01ba fileinfo: Upgrade to libmagic 5.39
Signed-off-by: Anatol Belski <ab@php.net>
2020-08-29 02:05:56 +02:00
George Peter Banyard
1b2ec73c1d Drop various unused macros/APIs
Also convert_libmagic_pattern() to return a zend_string*

Closes GH-6029
2020-08-26 12:59:43 +02:00
George Peter Banyard
457380cae7 Drop wchar header check as always defined since C95 2020-03-31 00:14:56 +02:00
Nikita Popov
d4ba1fd963 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #74170: locale information change after mime_content_type
2019-12-20 11:24:03 +01:00
Sergei Turchanov
c62cd9a43a Fix #74170: locale information change after mime_content_type
Some functions in libmagic (distributed with fileinfo extension) perform this sequence of calls:
func() {
setlocale(LC_TYPE, "C")
.. do some work ..
setlocale(LC_TYPE, "")
}

It effectively resets LC_TYPE if it that was set before the function call.

To avoid manipulations with current locale at all, the problematic functions
were modified to use locale-independent functions.
2019-12-20 11:22:59 +01:00
Peter Kokot
f002761e08 Update libmagic patch
This simplifies the libmagic patch:
- in upstream the HAVE_STRERROR check has been removed
- in upstream library the HAVE_SIGNAL_H has been removed
- indentations syncs with the upstream library
- some irrelevant changes removed from the patch (log comment), upstream
  has this correctly logged already so no need to patch the comment.

Closes GH-4298
2019-07-08 12:38:47 +02:00
Anatol Belski
622b10f06e Ported limagic 5.37 2019-05-30 02:22:40 +02:00
Fabien Villepinte
b6f9ade9f2 Remove unused variables 2019-03-17 23:29:51 +01:00
Anatol Belski
29dcf19f8b Declare function proto in header 2018-11-05 21:29:35 +01:00
Anatol Belski
e1af7a794a Fix possible stack buffer overflow 2018-08-04 16:56:08 +02:00
Dmitry Stogov
5eb1f92f31 Use zend_string_release_ex() instread of zend_string_release() in places, where we sure about string persistence. 2018-05-28 16:27:12 +03:00
Anatol Belski
94699d2ade Use suitable datatypes 2018-04-30 14:27:11 +02:00
Anatol Belski
e2182a1ba7 Port libmagic 5.33 2018-04-29 16:02:08 +02:00
Anatol Belski
a5bc5aed71 Patch core for PCRE2 support
RFC https://wiki.php.net/rfc/pcre2-migration
2017-11-13 19:37:38 +01:00
Anatol Belski
08d8623dec Upgrade bundled libmagic to 5.31 2017-10-11 18:18:55 +02:00
Dmitry Stogov
71daef93bc preg_replace() optimization 2017-06-07 13:50:16 +03:00
Anatol Belski
411e97c72d Upgraded libmagic to 5.29
yet unfinished port to libmagic 5.28

catch with missing libmagic port pieces

regenerate data file with magic from 5.28

test magic files from 5.28

missing files

fix path

pure c99 is still not supported

move right to 5.29, yet some bugs present

more sync with orig lib

more ZMM usage

use unpatched data for now

partial revert according to bug #67705

Revert "more ZMM usage"

This reverts commit 5e3c9b851034b455942b219b18bdc49c8315c3ee.

several fixes, so it's now closer to the clean port
2016-11-24 13:44:04 +01:00
Anatol Belski
e6bb7eb3aa Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  fix borked mainstream patch
  5.5.35 now
2016-03-31 01:38:22 +02:00
Anatol Belski
a00c2b1bf5 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  fix borked mainstream patch
  5.5.35 now
2016-03-31 01:36:47 +02:00
Anatol Belski
4b0b1cec00 fix borked mainstream patch 2016-03-31 01:33:38 +02:00
Anatol Belski
84990ab346 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  Fixed bug #71527 Buffer over-write in finfo_open with malformed magic file
2016-03-29 13:11:17 +02:00
Anatol Belski
fe13566c93 Fixed bug #71527 Buffer over-write in finfo_open with malformed magic file
The actual fix is applying the upstream patch from
6713ca45e7
2016-03-29 13:10:39 +02:00
Anatol Belski
e93c6910fc Fixed bug #71527 Buffer over-write in finfo_open with malformed magic file
The actual fix is applying the upstream patch from
6713ca45e7
2016-03-28 00:45:19 +02:00
Xinchen Hui
4cb47bd3bd Fixed compiler warnings 2016-01-25 11:45:14 +08:00
Dmitry Stogov
4a2e40bb86 Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 04:05:24 +03:00
Anatol Belski
2fd282a690 use right memory api 2015-03-08 19:47:12 +01:00
Anatol Belski
2181ed2e2a started to patch for libmagic.next
everything is broken yet
2015-03-08 19:47:06 +01:00
Dmitry Stogov
4241a090ad Avoid reallocation in preg_replace() if nothing was replaced 2015-02-10 13:30:25 +03:00
Stanislav Malyshev
b7a7b1a624 trailing whitespace removal 2015-01-10 15:07:38 -08:00
Anatol Belski
bdeb220f48 first shot remove TSRMLS_* things 2014-12-13 23:06:14 +01:00
Anatol Belski
c00424e427 bring back all the TSRMLS_FETCH() stuff
for better comparability with the mainstream
2014-10-15 09:37:55 +02:00
Anatol Belski
26e5f9bab7 cleanup TSRMLS_FETCH in ext/fileinfo 2014-09-26 21:30:22 +02:00
Anatol Belski
f4ebeead5d Merge branch 'PHP-5.6'
* PHP-5.6:
  Fixed bug #67731 finfo::file() returns invalid mime type for binary files
2014-08-30 04:05:42 +02:00
Anatol Belski
c301467f9b Fixed bug #67731 finfo::file() returns invalid mime type for binary files 2014-08-30 04:04:42 +02:00
Anatol Belski
c3e3c98ec6 master renames phase 1 2014-08-25 19:24:55 +02:00
Xinchen Hui
9ef21b7606 Refactor fileinfo 2014-05-07 13:50:29 +08:00
Anatol Belski
62f6c5853f Fixes to various stream cast on win64
This fixes further issues on win64 with casts from the streams.
Sockets/descriptors handling was unitized. This has an impact only on
win64, php_socket_t otherwise can be feed back to int datatype.
2014-03-19 06:33:46 +01:00
Anatol Belski
967a6771d3 updated to libmagic-5.17 2014-02-19 10:02:36 +01:00
Remi Collet
89f864c547 Fixed Bug #66731 file: infinite recursion
Upstream commit (available in file-5.17)

3c081560c2
cc9e74dfec
2014-02-18 13:54:33 +01:00
Anatol Belski
10367fa7c6 upgraded libmagic to 5.14 2013-04-07 22:15:56 +02:00