Compare commits

...
126 Commits
Author SHA1 Message Date
Derick Rethans acfdeccb2e Update versions for PHP 7.4.4 2020-03-17 10:40:15 +00:00
Derick Rethans 8a7251c3b4 Update NEWS for PHP 7.4.4 2020-03-17 10:40:15 +00:00
Derick Rethans 2c24590d6e Update NEWS 2020-03-17 10:38:49 +00:00
Stanislav Malyshev 919e91f841 Fix test 2020-03-17 09:47:27 +00:00
Stanislav Malyshev a33d05b147 Fix bug #79329 - get_headers should not accept \0 2020-03-17 09:47:21 +00:00
Stanislav Malyshev 0c77b4307d Fixed bug #79282 2020-03-17 09:47:14 +00:00
Christoph M. Becker 54bccd7345 Fix #79283: Segfault in libmagic patch contains a buffer overflow
To solve this, we properly calculate the required string length upfront
instead of allocating an oversized string (`len * 4 + 4`).
2020-03-17 09:47:02 +00:00
Christoph M. Becker 69155120e6 Fix #79371: mb_strtolower (UTF-32LE): stack-buffer-overflow
We make sure that negative values are properly compared.
2020-03-17 09:46:41 +00:00
Remi Collet e2b5f18896 this test needs json 2020-03-03 12:57:40 +00:00
Derick Rethans a8ceab8cda Update NEWS for PHP 7.4.4RC1 2020-03-03 11:16:39 +00:00
Christoph M. Becker 22307b4c44 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Next is 7.3.17
2020-03-03 10:20:42 +01:00
Christoph M. Becker 9dda3b9eb2 Next is 7.3.17 2020-03-03 10:19:31 +01:00
Christoph M. Becker fc8b3ab7cb Fix #79013: Content-Length missing when posting a curlFile with curl
Unfortunately, some Webservers (e.g. IIS) do not implement the (F)CGI
specifications correctly wrt. chunked uploads (i.e. Transfer-encoding:
chunked), but instead pass -1 as CONTENT_LENGTH to the CGI
application. However, our (F)CFI SAPIs (i.e. cgi and cgi-fcgi) do not
support this.

Therefore we try to retrieve the stream size in advance and pass it to
`curl_mime_data_cb()` to prevent libcurl from doing chunked uploads.
This is basically the same approach that `curl_mime_filedata()`
implements, except that we are keeping already opened streams open for
the `read_cb()`.
2020-03-02 19:11:33 +01:00
Christoph M. Becker a0377021c5 Native Windows support for mysqlnd sha256 authentification
We implement that on top of Cryptography API: Next Generation (CNG).
2020-03-02 16:32:51 +01:00
Christoph M. Becker a7400d5fd3 Abstract over crypto operations 2020-03-02 16:26:53 +01:00
Christoph M. Becker 7fa6e2a25c Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Update libmagic.patch
2020-03-02 15:08:50 +01:00
Christoph M. Becker f15ab32af8 Update libmagic.patch
Some commits missed to update the patch file, so we're catching up on
this.

To generally make this easier, we back-port generate_patch.sh from
PHP-7.4, where we now also generate magic.h from magic.h.in.
2020-03-02 15:03:45 +01:00
Christoph M. Becker 318757551a Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79333: com_print_typeinfo() leaks memory
2020-03-02 11:38:03 +01:00
Christoph M. Becker 53140e5c56 Fix #79333: com_print_typeinfo() leaks memory
We have to free the `ansiname`s, regardless of whether they have been
put into the hashtable or not.

Since bug79299.phpt already shows the leak when run with a leak
checker, there is no need for another regression test.
2020-03-02 11:36:30 +01:00
Christoph M. Becker b9843c9418 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79332: php_istreams are never freed
2020-03-02 10:46:46 +01:00
Christoph M. Becker 2adf1c4d23 Fix #79332: php_istreams are never freed
Releasing the `com_dotnet_istream_wrapper` in `istream_destructor()` is
pointless, since `istream_destructor()` is only called when the
resource is going to be released.  This recursion is not a real issue,
though, since the resource is never exposed to userland, and has at
most refcount 1, so due to well defined unsigned integer underflow, it
never is released twice.  However, returning early in this case causes
a memory leak which needs to be fixed.
2020-03-02 10:45:37 +01:00
Nikita Popov 533633deda Remove generated lexer
Accidentially committed this when merging from 7.3.
2020-02-28 17:25:47 +01:00
Nikita Popov 375191aae7 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79062
2020-02-28 17:07:36 +01:00
Nikita Popov 6c48da9a50 Fixed bug #79062
Back up the doc comment when performing heredoc scanahead.
2020-02-28 17:06:05 +01:00
Christoph M. Becker 0bffee4a35 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79311: enchant_dict_suggest() fails on big endian architecture
2020-02-28 15:44:52 +01:00
Christoph M. Becker 6adb885966 Fix #79311: enchant_dict_suggest() fails on big endian architecture
For obvious reasons, we must not assign a `size_t` value to an `int`
variable using memcpy().  However, there is actually no need for the
intermediate `n_sugg_st` here, if we use the proper types in the first
place.

A regression test is not necessary, because dict_suggest.phpt already
exhibits the erroneous behavior on big endian architectures.
2020-02-28 15:43:44 +01:00
Nikita Popov a7de98fb12 Try to fix msvc build 2020-02-28 14:48:02 +01:00
Nikita Popov b2d01e0be8 Fix another flaky FPM test 2020-02-28 14:40:21 +01:00
Nikita Popov 3c096b51f9 Try to fix intermittent FPM failures
Terminate only after expecting the log lines to avoid race
condition.
2020-02-28 13:19:10 +01:00
Nikita Popov 30ee3f48d4 Fixed bug #79252 2020-02-28 12:47:56 +01:00
Remi Collet 5b82fd491a fix test 2020-02-28 10:39:08 +01:00
Remi Collet 1b40bb76b9 NEWS 2020-02-28 10:36:12 +01:00
Remi Collet 7f0d3f1eab Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79315 ZipArchive::addFile doesn't honor start/length parameters
2020-02-28 10:35:39 +01:00
Remi Collet d31fc591e0 Fix #79315 ZipArchive::addFile doesn't honor start/length parameters 2020-02-28 10:29:50 +01:00
Nikita Popov 6d19acf54b Use type-checked ref assignment in UConverter 2020-02-28 10:21:50 +01:00
Dmitry Stogov cb88184420 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed incorrect overflow detection
2020-02-27 23:38:09 +03:00
Dmitry Stogov 5b51b633e2 Fixed incorrect overflow detection 2020-02-27 23:37:41 +03:00
Christoph M. Becker ac2382d437 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Add upgrading node regarding fix for bug #79271
2020-02-27 10:37:52 +01:00
Christoph M. Becker 49762c84e0 Add upgrading node regarding fix for bug #79271
Cf. <https://github.com/php/php-src/pull/5180#issuecomment-590259750>ff.
2020-02-27 10:33:20 +01:00
Dmitry Stogov d9f56903ad Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed incorrect behavior of internal memory debugger
2020-02-27 12:27:58 +03:00
Dmitry Stogov 45b4368d5c Fixed incorrect behavior of internal memory debugger 2020-02-27 12:27:22 +03:00
Christoph M. Becker 78e04759ad Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #64032: mysqli reports different client_version
2020-02-27 09:39:13 +01:00
Christoph M. Becker 8654c32b58 Fix #64032: mysqli reports different client_version
While `mysqli_get_client_version()` calls `mysql_get_client_version()`
to retrieve the client version, `mysql::$client_version` is initialized
to `MYSQL_VERSION_ID`.  Both should match though, and since the former
is the more useful information, we fix `mysql::$client_version`.

We do not add a regression test, because it would usually succeed
anyway, and we already have several tests with respective `assert()`s.
2020-02-27 09:35:04 +01:00
Nikita Popov 8c8f8c4193 Add test for bug #60161
This has been fixed in PHP 7.4, let's make sure it stays fixed.
2020-02-26 16:48:03 +01:00
Nikita Popov 1e50c81f6f Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #63206: Fully support error/exception_handler stacking, even with null or inside the handler
2020-02-25 12:44:11 +01:00
Mark Plomer 8c6a7c3326 Fix #63206: Fully support error/exception_handler stacking, even with null or inside the handler
Always push the current user_error/exception_handler to the stack,
even when it is empty, so restore_error_handler() always works as
expected.

The user_error_handler is especially temporarily empty when we are inside
the error handler, which caused inconsistent behaviour before.
2020-02-25 12:43:42 +01:00
Nikita Popov 2d15845ae1 Enable ext/sodium in CI 2020-02-24 12:41:30 +01:00
Nikita Popov 6c0a33f2dc Add skipif for argon2id in test
If argon2i is provided by libargon, then argon2id may not be
available here.
2020-02-24 12:41:24 +01:00
Nikita Popov c5128fb7fc Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Don't treat any WS as start of header
2020-02-24 10:20:43 +01:00
Nikita Popov 56cdbe63c2 Don't treat any WS as start of header
Check that the header occurs after \n, not other whitespace
characters.
2020-02-24 10:20:33 +01:00
Nikita Popov 8d451fd24e Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Reduce code duplication in HTTP header checks
2020-02-24 10:03:30 +01:00
Nikita Popov 3d9c02364d Reduce code duplication in HTTP header checks 2020-02-24 10:03:05 +01:00
Nikita Popov e855b286c8 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixes #79265: Improper injection of Host header when using fopen for http requests
2020-02-24 09:51:36 +01:00
Miguel Xavier Penha Neto d0d60503b5 Fixes #79265: Improper injection of Host header when using fopen for http requests
Check all occurrences of the string "host:" (and other headers),
not just the first one.
2020-02-24 09:50:32 +01:00
Christoph M. Becker 09e7c86779 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79299: com_print_typeinfo prints duplicate variables
2020-02-23 23:34:15 +01:00
Christoph M. Becker 9e6358af36 Fix #79299: com_print_typeinfo prints duplicate variables
`lastid` has to retain its value during the traversal, so we move it to
an outer scope.

Patch contributed by Litiano Moura.
2020-02-23 23:31:36 +01:00
Jakub Zelenka 578a8113eb Fix bug #79014 (PHP-FPM & Primary script unknown) 2020-02-23 19:14:05 +00:00
Jakub Zelenka 0bc6a66a7a Fix bug #77653 (operator displayed instead of the real error message) 2020-02-23 18:29:10 +00:00
Christoph M. Becker 2a76e3a457 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79294: ::columnType() may fail after SQLite3Stmt::reset()
2020-02-21 13:37:31 +01:00
Christoph M. Becker f133f0024e Fix #79294: ::columnType() may fail after SQLite3Stmt::reset()
The fix for feature request #53466 did not properly handle resetting of
the corresponding statement; the problem with this is that the
statement does not know about its result sets.  But even if we could
fix this, the `complete` handling still appears to be brittle, since
the `sqlite3_column_type()`docs[1] state:

| If the SQL statement does not currently point to a valid row, or if
| the column index is out of range, the result is undefined.

Fortunately, we can use `sqlite3_data_count()` instead, since[2]:

| If prepared statement P does not have results ready to return (via
| calls to the sqlite3_column() family of interfaces) then
| sqlite3_data_count(P) returns 0.

Thus, we guard `SQLite3::columnType()` with `sqlite3_data_count()`, and
completely drop updating the `php_sqlite3_result_object.complete`
field, but keep it for ABI BC purposes.

[1] <https://www.sqlite.org/c3ref/column_blob.html>
[2] <https://www.sqlite.org/c3ref/data_count.html>
2020-02-21 13:36:29 +01:00
Nikita Popov 5a5680c25b Don't use asm arithmetic under msan
Clang 9 supports asm goto, so these no longer get automatically
skipped.

(cherry picked from commit 33bf1495b2)
2020-02-21 11:58:52 +01:00
Christoph M. Becker 1c6b084262 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Add test for bug #78569
2020-02-21 10:32:45 +01:00
Christoph M. Becker ad000a63e8 Add test for bug #78569 2020-02-21 10:31:26 +01:00
Nikita Popov 2b50d905df Update Ubuntu version on Azure
The i386 and community jobs were still on 16.04, update them to
18.04.
2020-02-21 10:12:31 +01:00
Christoph M. Becker 1b2e6cb3f5 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix NEWS [ci skip]
2020-02-20 10:57:41 +01:00
Christoph M. Becker ab5b6702d7 Fix NEWS [ci skip]
Cosmetics.
2020-02-20 10:55:17 +01:00
Nikita Popov 9d31a42a30 Don't use VLA in mysqlnd auth
We use alloca instead of VLA. This should also allow building
this code on Windows.
2020-02-18 16:17:56 +01:00
Christoph M. Becker f6fcc5c353 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Remove extra tab in NEWS [ci skip]
2020-02-18 11:10:51 +01:00
Christoph M. Becker 31dd45564c Remove extra tab in NEWS [ci skip] 2020-02-18 11:09:37 +01:00
Remi Collet 9f8c32cced Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  bump version to 7.2.29
2020-02-18 11:01:07 +01:00
Remi Collet 2aecf3aba9 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  bump version to 7.2.29
2020-02-18 11:00:49 +01:00
Remi Collet 63f6608f89 bump version to 7.2.29 2020-02-18 11:00:28 +01:00
Christoph M. Becker 3090c88f55 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79038: PDOStatement::nextRowset() leaks column values
2020-02-17 22:54:16 +01:00
Christoph M. Becker 08073b0658 Fix #79038: PDOStatement::nextRowset() leaks column values
Firstly, we must not rely on `stmt->column_count` when freeing the
driver specific column values, but rather store the column count in
the driver data.  Since the column count is a `short`, 16 bit are
sufficient, so we can store it in reserved bits of `pdo_odbc_stmt`.

Furthermore, we must not allocate new column value storage when the
statement is not executed, but rather when the column value storage has
not been allocated.

Finally, we have to introduce a driver specific `cursor_closer` to
avoid that `::closeCursor()` calls `odbc_stmt_next_rowset()` which then
frees the column value storage, because it may be still needed for
bound columns.
2020-02-17 22:53:02 +01:00
Christoph M. Becker 8db8d66df0 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix NEWS [ci skip]
2020-02-17 19:36:52 +01:00
Christoph M. Becker 16c7c71693 Fix NEWS [ci skip] 2020-02-17 19:35:42 +01:00
Christoph M. Becker 583e7bad79 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Update NEWS [ci skip]
2020-02-17 19:24:39 +01:00
Christoph M. Becker 788065fb8c Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Update NEWS [ci skip]
2020-02-17 19:23:31 +01:00
Christoph M. Becker 5009b9811d Update NEWS [ci skip] 2020-02-17 19:21:51 +01:00
Christoph M. Becker e33ab23c83 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix # 79171: heap-buffer-overflow in phar_extract_file
  Fix bug #79082 - Files added to tar with Phar::buildFromIterator have all-access permissions
  Fix bug #79221 - Null Pointer Dereference in PHP Session Upload Progress
  Mark bug76348.phpt as online test
  Fix bug #79082 - Files added to tar with Phar::buildFromIterator have all-access permissions
  Fix bug #79221 - Null Pointer Dereference in PHP Session Upload Progress
2020-02-17 19:08:22 +01:00
Christoph M. Becker 2831334bd3 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Mark bug76348.phpt as online test
  Fix bug #79082 - Files added to tar with Phar::buildFromIterator have all-access permissions
  Fix bug #79221 - Null Pointer Dereference in PHP Session Upload Progress
2020-02-17 19:08:04 +01:00
Christoph M. Becker e1de11d467 Create a new console for each test worker on Windows
The primary motivation to have each test worker running its own console
is to allow the windows_mb_path tests to run in parallel.  A nice side
effect is that this also prevents changing the code page of the
tester's console window (which can even cause its font to be changed).

To be able to do so, we introduce the `create_new_console` option for
`proc_open()`, which might occasionally be useful for other purposes
than testing.
2020-02-17 18:52:45 +01:00
Dmitry Stogov 54ecf57fe2 Disable instantiation of zero size FFI\CData objects 2020-02-17 12:48:55 +03:00
Christoph M. Becker b01b1f65e7 Fix # 79171: heap-buffer-overflow in phar_extract_file
We must not access memory outside of the allocated buffer.
2020-02-17 00:20:17 -08:00
Stanislav Malyshev bbcb8cab8c Fix bug #79082 - Files added to tar with Phar::buildFromIterator have all-access permissions 2020-02-17 00:20:17 -08:00
Stanislav Malyshev 282bfb109e Fix bug #79221 - Null Pointer Dereference in PHP Session Upload Progress 2020-02-17 00:20:17 -08:00
Christoph M. Becker 7df594b943 Fix # 79171: heap-buffer-overflow in phar_extract_file
We must not access memory outside of the allocated buffer.
2020-02-17 00:20:04 -08:00
Stanislav Malyshev 6facfa59a5 Fix bug #79082 - Files added to tar with Phar::buildFromIterator have all-access permissions 2020-02-17 00:19:30 -08:00
Stanislav Malyshev 409965fe1c Fix bug #79221 - Null Pointer Dereference in PHP Session Upload Progress 2020-02-17 00:19:30 -08:00
Christoph M. Becker 73a4c50309 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79271: DOMDocumentType::$childNodes is NULL
2020-02-17 09:09:30 +01:00
Christoph M. Becker 0966941130 Fix #79271: DOMDocumentType::$childNodes is NULL
Dom level 2 core, DOM level 3 core and the DOM living standard agree
that `childNodes` always return a `NodeList`, and never `null`.
2020-02-17 09:07:54 +01:00
Nikita Popov 2826364298 Mark bug76348.phpt as online test 2020-02-16 22:40:25 -08:00
Stanislav Malyshev e5c95234d8 Fix bug #79082 - Files added to tar with Phar::buildFromIterator have all-access permissions 2020-02-16 22:38:38 -08:00
Stanislav Malyshev d76f7c6c63 Fix bug #79221 - Null Pointer Dereference in PHP Session Upload Progress 2020-02-15 20:52:19 -08:00
Christoph M. Becker 8ec76366d0 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix typo in recent bugfix
2020-02-14 09:23:43 +01:00
Christoph M. Becker 392dada1d6 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix typo in recent bugfix
2020-02-14 09:22:51 +01:00
Christoph M. Becker 8308196c97 Fix typo in recent bugfix 2020-02-14 09:21:13 +01:00
Nikita Popov 9c8cc480ba Fix Azure MacOS build 2020-02-13 16:18:07 +01:00
Christoph M. Becker bf8c6519fb Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #77569: Write Acess Violation in DomImplementation
2020-02-13 15:16:09 +01:00
Christoph M. Becker 8ebadd1128 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77569: Write Acess Violation in DomImplementation
2020-02-13 15:15:05 +01:00
Christoph M. Becker cec8b24c84 Fix #77569: Write Acess Violation in DomImplementation
We must not assume that the zval IS_STRING.
2020-02-13 15:13:26 +01:00
Michael Voříšek 61e76927b4 Remove value from comment in php.ini files
Closes GH-5164.
2020-02-12 12:18:22 +01:00
Nikita Popov 3a51530963 Fixed bug #79257
Replace an existing entry for a given name only if we have a match.
2020-02-11 17:31:48 +01:00
Christoph M. Becker 93b183ed55 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79254: getenv() w/o arguments not showing changes
2020-02-11 11:57:57 +01:00
Christoph M. Becker 7b464ce6f3 Fix #79254: getenv() w/o arguments not showing changes
To be able to see changes done only with `SetEnvironmentVariable()`, we
have to use `GetEnvironmentStrings()` instead of `environ`, because the
latter sees only changes done with `putenv()`.

For best backward compatibility we're using `GetEnvironmentStringsA()`;
switching to the wide string version likely makes sense for master,
though.
2020-02-11 11:47:29 +01:00
jsmmo 038ca4bb07 Remove hint to security purpose of disable_functions
These features are not intended to offer security against a
determined attacher with full local code execution privileges.

Closes GH-5150.
2020-02-10 10:05:09 +01:00
Xinchen Hui 6295ff77b7 Fixed bug #79244 (php crashes during parsing INI file). (Laruence)
Cherry-picked the fix(not sure why this wasn't merged to 7.4) for:
Fixed bug #77589 (Core dump using parse_ini_string with numeric sections)

Section name should not be typed(NULL, FALSE, TRUE etc)

Conflicts:

	Zend/zend_ini_scanner.c
2020-02-10 13:01:51 +08:00
Christoph M. Becker 01eab11cee Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79248: Traversing empty VT_ARRAY throws com_exception
2020-02-08 17:07:02 +01:00
Christoph M. Becker f649adedfe Fix #79248: Traversing empty VT_ARRAY throws com_exception
If the `VT_ARRAY` is empty, i.e. its upperbound is less than its lower
bound, we must not call `php_com_safearray_get_elem()`, because that
function throws in this case.
2020-02-08 17:05:29 +01:00
Christoph M. Becker b4f61d99cf Fix #79247: Garbage collecting variant objects segfaults
variant objects have no (declared) properties, so the `get_properties`
handlers returns a pointer to constant storage for efficiency reasons.
This pointer must not be returned from the `get_gc` handler, though;
instead we set up an own `get_gc` handler and return NULL from it, to
signal that there are no properties to collect.
2020-02-08 11:03:52 +01:00
Anatol Belski 34bab6c9fc Update bundled stdxx check macros 2020-02-08 10:13:46 +01:00
Christoph M. Becker bcfb7b2be9 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Skip test case on x86 where it otherwise fails [ci skip]
2020-02-07 21:10:44 +01:00
Christoph M. Becker 674d44ad7c Skip test case on x86 where it otherwise fails [ci skip]
`-2200000000` can't be converted to integer on x86, so the constructor
call would fail.
2020-02-07 21:09:35 +01:00
Christoph M. Becker 7f86f9972e Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79242: COM error constants don't match com_exception codes
2020-02-07 18:05:10 +01:00
Christoph M. Becker b9738f5802 Fix #79242: COM error constants don't match com_exception codes
Because a `HRESULT` is a `LONG`[1], no special treatment is required on
x86 platforms to get appropriate values.  On x64 platforms we prefer
positive values, what we could accomplish by casting the `HRESULT`
value to `ULONG` and then to `zend_long`, but since the current
behavior is correct and the performance improvement is negligible, we
defer that to master.

[1] <https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types#hresult>
2020-02-07 18:04:14 +01:00
Nikita Popov cd5591a28d PCRE: Only remember valid UTF-8 if start offset zero
PCRE only validates the string starting from the start offset
(minus maximum look-behind, but let's ignore that), so we can
only remember that the string is fully valid UTF-8 is the original
start offset is zero.
2020-02-07 17:01:39 +01:00
Nikita Popov c9e78e6d33 PCRE: Check whether start offset is on char boundary
We need not just the whole string to be UTF-8, but the start
position to be on a character boundary as well. Check this by
looking for a continuation byte.
2020-02-07 16:49:28 +01:00
Christoph M. Becker 0d49cf4ed2 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #66322: COMPersistHelper::SaveToFile can save to wrong location
2020-02-06 15:01:12 +01:00
Christoph M. Becker 5e2ea00b15 Fix #66322: COMPersistHelper::SaveToFile can save to wrong location
Saving under the given `filename` may also work, but since
`::LoadFromFile` uses the `fullpath` we follow suit.
2020-02-06 14:59:55 +01:00
Dmitry Stogov 5d0ef4c239 Make opcodes to return de-refereced values of typed references (in the same was as for non-typed) 2020-02-06 15:48:54 +03:00
Christoph M. Becker 1cffc7b97a Fix NEWS [ci skip]
This bugfix didn't make it into 7.4.3.
2020-02-06 10:49:05 +01:00
Nikita Popov e30f52b919 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79188
2020-02-05 11:21:25 +01:00
Nikita Popov 13bfa9f5ac Fixed bug #79188 2020-02-05 11:18:46 +01:00
Christoph M. Becker d9f51e0e49 Merge branch 'PHP-7.3' into PHP-7.4 [ci skip]
* PHP-7.3:
  Next is 7.3.16
2020-02-04 11:46:15 +01:00
Christoph M. Becker e3632fdc0d Next is 7.3.16 2020-02-04 11:38:29 +01:00
Christoph M. Becker 2d0dec91a5 Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times.  Instead, we're opening the stream
lazily in the read callback.

Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence.  Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.

In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 11:09:28 +01:00
113 changed files with 2112 additions and 491 deletions

No files matched your search

+1
View File
@@ -27,6 +27,7 @@ addons:
- libpspell-dev
- libsasl2-dev
- libsqlite3-dev
- libsodium-dev
- libtidy-dev
- libwebp-dev
- libxml2-dev
+100 -2
View File
@@ -1,6 +1,96 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 7.4.3
19 Mar 2020, PHP 7.4.4
- Core:
. Fixed bug #79329 (get_headers() silently truncates after a null byte)
(CVE-2020-7066) (cmb)
. Fixed bug #79244 (php crashes during parsing INI file). (Laruence)
. Fixed bug #63206 (restore_error_handler does not restore previous errors
mask). (Mark Plomer)
- COM:
. Fixed bug #66322 (COMPersistHelper::SaveToFile can save to wrong location).
(cmb)
. Fixed bug #79242 (COM error constants don't match com_exception codes on
x86). (cmb)
. Fixed bug #79247 (Garbage collecting variant objects segfaults). (cmb)
. Fixed bug #79248 (Traversing empty VT_ARRAY throws com_exception). (cmb)
. Fixed bug #79299 (com_print_typeinfo prints duplicate variables). (Litiano
Moura)
. Fixed bug #79332 (php_istreams are never freed). (cmb)
. Fixed bug #79333 (com_print_typeinfo() leaks memory). (cmb)
- CURL:
. Fixed bug #79019 (Copied cURL handles upload empty file). (cmb)
. Fixed bug #79013 (Content-Length missing when posting a curlFile with
curl). (cmb)
- DOM:
. Fixed bug #77569: (Write Access Violation in DomImplementation). (Nikita,
cmb)
. Fixed bug #79271 (DOMDocumentType::$childNodes is NULL). (cmb)
- Enchant:
. Fixed bug #79311 (enchant_dict_suggest() fails on big endian architecture).
(cmb)
- EXIF:
. Fixed bug #79282 (Use-of-uninitialized-value in exif) (CVE-2020-7064)
(Nikita)
- Fileinfo:
. Fixed bug #79283 (Segfault in libmagic patch contains a buffer
overflow) (cmb)
- FPM:
. Fixed bug #77653 (operator displayed instead of the real error message).
(Jakub Zelenka)
. Fixed bug #79014 (PHP-FPM & Primary script unknown). (Jakub Zelenka)
- MBstring:
. Fixed bug #79371 (mb_strtolower (UTF-32LE): stack-buffer-overflow at
php_unicode_tolower_full) (CVE-2020-7065) (cmb)
- MySQLi:
. Fixed bug #64032 (mysqli reports different client_version). (cmb)
- MySQLnd:
. Implemented FR #79275 (Support auth_plugin_caching_sha2_password on
Windows). (cmb)
- Opcache:
. Fixed bug #79252 (preloading causes php-fpm to segfault during exit).
(Nikita)
- PCRE:
. Fixed bug #79188 (Memory corruption in preg_replace/preg_replace_callback
and unicode). (Nikita)
. Fixed bug #79241 (Segmentation fault on preg_match()). (Nikita)
. Fixed bug #79257 (Duplicate named groups (?J) prefer last alternative even
if not matched). (Nikita)
- PDO_ODBC:
. Fixed bug #79038 (PDOStatement::nextRowset() leaks column values). (cmb)
- Reflection:
. Fixed bug #79062 (Property with heredoc default value returns false for
getDocComment). (Nikita)
- SQLite3:
. Fixed bug #79294 (::columnType() may fail after SQLite3Stmt::reset()). (cmb)
- Standard:
. Fixed bug #79254 (getenv() w/o arguments not showing changes). (cmb)
. Fixed bug #79265 (Improper injection of Host header when using fopen for
http requests). (Miguel Xavier Penha Neto)
- Zip:
. Fixed bug #79315 (ZipArchive::addFile doesn't honor start/length
parameters). (Remi)
20 Feb 2020, PHP 7.4.3
- Core:
. Fixed bug #79146 (cscript can fail to run on some systems). (clarodeus)
@@ -24,7 +114,7 @@ PHP NEWS
. Fixed bug #79112 (IMAP extension can't find OpenSSL libraries at configure
time). (Nikita)
-Intl:
- Intl:
. Fixed bug #79212 (NumberFormatter::format() may detect wrong type). (cmb)
- Libxml:
@@ -55,12 +145,20 @@ PHP NEWS
. Fixed bug #79145 (openssl memory leak). (cmb, Nikita)
- Phar:
. Fixed bug #79082 (Files added to tar with Phar::buildFromIterator have
all-access permissions). (CVE-2020-7063) (stas)
. Fixed bug #79171 (heap-buffer-overflow in phar_extract_file).
(CVE-2020-7061) (cmb)
. Fixed bug #76584 (PharFileInfo::decompress not working). (cmb)
- Reflection:
. Fixed bug #79115 (ReflectionClass::isCloneable call reflected class
__destruct). (Nikita)
- Session:
. Fixed bug #79221 (Null Pointer Dereference in PHP Session Upload Progress).
(CVE-2020-7062) (stas)
- Standard:
. Fixed bug #78902 (Memory leak when using stream_filter_append). (liudaixiao)
. Fixed bug #78969 (PASSWORD_DEFAULT should match PASSWORD_BCRYPT instead of being null). (kocsismate)
+6
View File
@@ -69,6 +69,12 @@ PHP 7.4 UPGRADE NOTES
a warning and always return false. Previously all DateInterval objects were
considered equal, unless they had properties.
DOM:
. As of PHP 7.4.4, the value of the $childNodes property of DOMDocument,
DOMNode, DOMProcessingInstruction, DOMComment, DOMText, DOMCdataSection and
DOMNotation is now an empty DOMNodeList instead of NULL, according to the
W3C and WHATWG standards and the PHP manual.
- Intl:
. The default parameter value of idn_to_ascii() and idn_to_utf8() is now
INTL_IDNA_VARIANT_UTS46 instead of the deprecated INTL_IDNA_VARIANT_2003.
+18
View File
@@ -0,0 +1,18 @@
--TEST--
Bug #60161: Implementing an interface extending Traversable is order dependent
--FILE--
<?php
interface Foo extends Traversable {
}
class Example implements Foo, IteratorAggregate {
public function getIterator() {
return new ArrayIterator([]);
}
}
?>
===DONE===
--EXPECT--
===DONE===
+29
View File
@@ -0,0 +1,29 @@
--TEST--
Bug #63206 Fully support error_handler stacking, even inside the error_handler
--FILE--
<?php
set_error_handler(function() {
echo 'First handler' . PHP_EOL;
});
set_error_handler(function() {
echo 'Second handler' . PHP_EOL;
set_error_handler(function() {
echo 'Internal handler' . PHP_EOL;
});
$triggerInternalNotice++; // warnings while handling the error should go into internal handler
restore_error_handler();
});
$triggerNotice1++;
$triggerNotice2++;
?>
--EXPECTF--
Second handler
Internal handler
Second handler
Internal handler
+26
View File
@@ -0,0 +1,26 @@
--TEST--
Bug #63206 Fully support error_handler stacking, even with null
--FILE--
<?php
set_error_handler(function() {
echo 'First handler' . PHP_EOL;
});
set_error_handler(function() {
echo 'Second handler' . PHP_EOL;
});
set_error_handler(null);
set_error_handler(function() {
echo 'Fourth handler' . PHP_EOL;
});
restore_error_handler();
restore_error_handler();
$triggerNotice++;
?>
--EXPECTF--
Second handler
+26
View File
@@ -0,0 +1,26 @@
--TEST--
Bug #63206 Fully support exception_handler stacking, even with null
--FILE--
<?php
set_exception_handler(function() {
echo 'First handler' . PHP_EOL;
});
set_exception_handler(function() {
echo 'Second handler' . PHP_EOL;
});
set_exception_handler(null);
set_exception_handler(function() {
echo 'Fourth handler' . PHP_EOL;
});
restore_exception_handler();
restore_exception_handler();
throw new Exception();
?>
--EXPECTF--
Second handler
+40
View File
@@ -0,0 +1,40 @@
--TEST--
BUG #77589 (Core dump using parse_ini_string with numeric sections)
--FILE--
<?php
var_dump(
parse_ini_string(<<<INI
[0]
a = 1
b = on
c = true
["true"]
a = 100
b = null
c = yes
INI
, TRUE, INI_SCANNER_TYPED));
?>
--EXPECT--
array(2) {
[0]=>
array(3) {
["a"]=>
int(1)
["b"]=>
bool(true)
["c"]=>
bool(true)
}
["true"]=>
array(3) {
["a"]=>
int(100)
["b"]=>
NULL
["c"]=>
bool(true)
}
}
+1
View File
@@ -2065,6 +2065,7 @@ static zend_long zend_mm_find_leaks(zend_mm_heap *heap, zend_mm_chunk *p, uint32
}
}
p = p->next;
i = ZEND_MM_FIRST_PAGE;
} while (p != heap->main_chunk);
return count;
}
+5 -5
View File
@@ -1645,11 +1645,11 @@ ZEND_FUNCTION(set_error_handler)
if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
ZVAL_COPY(return_value, &EG(user_error_handler));
zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting));
zend_stack_push(&EG(user_error_handlers), &EG(user_error_handler));
}
zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting));
zend_stack_push(&EG(user_error_handlers), &EG(user_error_handler));
if (Z_TYPE_P(error_handler) == IS_NULL) { /* unset user-defined handler */
ZVAL_UNDEF(&EG(user_error_handler));
return;
@@ -1712,10 +1712,10 @@ ZEND_FUNCTION(set_exception_handler)
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
ZVAL_COPY(return_value, &EG(user_exception_handler));
zend_stack_push(&EG(user_exception_handlers), &EG(user_exception_handler));
}
zend_stack_push(&EG(user_exception_handlers), &EG(user_exception_handler));
if (Z_TYPE_P(exception_handler) == IS_NULL) { /* unset user-defined handler */
ZVAL_UNDEF(&EG(user_exception_handler));
return;
+2 -2
View File
@@ -1740,11 +1740,11 @@ static void zend_pre_incdec_property_zval(zval *prop, zend_property_info *prop_i
do {
if (Z_ISREF_P(prop)) {
zend_reference *ref = Z_REF_P(prop);
prop = Z_REFVAL_P(prop);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_incdec_typed_ref(ref, NULL OPLINE_CC EXECUTE_DATA_CC);
break;
}
prop = Z_REFVAL_P(prop);
}
if (UNEXPECTED(prop_info)) {
@@ -1777,11 +1777,11 @@ static void zend_post_incdec_property_zval(zval *prop, zend_property_info *prop_
} else {
if (Z_ISREF_P(prop)) {
zend_reference *ref = Z_REF_P(prop);
prop = Z_REFVAL_P(prop);
if (ZEND_REF_HAS_TYPE_SOURCES(ref)) {
zend_incdec_typed_ref(ref, EX_VAR(opline->result.var) OPLINE_CC EXECUTE_DATA_CC);
return;
}
prop = Z_REFVAL_P(prop);
}
if (UNEXPECTED(prop_info)) {
+8 -7
View File
@@ -141,13 +141,14 @@ ZEND_API zend_ini_scanner_globals ini_scanner_globals;
ZVAL_NEW_STR(retval, zend_string_init(str, len, ZEND_SYSTEM_INI))
#define RETURN_TOKEN(type, str, len) { \
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_TYPED) { \
zend_ini_copy_typed_value(ini_lval, type, str, len); \
} else { \
zend_ini_copy_value(ini_lval, str, len); \
} \
return type; \
#define RETURN_TOKEN(type, str, len) { \
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_TYPED && \
(YYSTATE == STATE(ST_VALUE) || YYSTATE == STATE(ST_RAW))) {\
zend_ini_copy_typed_value(ini_lval, type, str, len); \
} else { \
zend_ini_copy_value(ini_lval, str, len); \
} \
return type; \
}
static inline int convert_to_number(zval *retval, const char *str, const int str_len)
+3
View File
@@ -2434,6 +2434,7 @@ skip_escape_conversion:
if (is_heredoc && !SCNG(heredoc_scan_ahead)) {
zend_lex_state current_state;
zend_string *saved_doc_comment = CG(doc_comment);
int heredoc_nesting_level = 1;
int first_token = 0;
int error = 0;
@@ -2444,6 +2445,7 @@ skip_escape_conversion:
SCNG(heredoc_indentation) = 0;
SCNG(heredoc_indentation_uses_spaces) = 0;
LANG_SCNG(on_event) = NULL;
CG(doc_comment) = NULL;
zend_ptr_stack_reverse_apply(&current_state.heredoc_label_stack, copy_heredoc_label_stack);
@@ -2493,6 +2495,7 @@ skip_escape_conversion:
zend_restore_lexical_state(&current_state);
SCNG(heredoc_scan_ahead) = 0;
CG(increment_lineno) = 0;
CG(doc_comment) = saved_doc_comment;
if (PARSER_MODE() && error) {
RETURN_TOKEN(T_ERROR);
+18 -12
View File
@@ -500,9 +500,15 @@ ZEND_API void zend_update_current_locale(void);
#define ZVAL_OFFSETOF_TYPE \
(offsetof(zval, u1.type_info) - offsetof(zval, value))
#if defined(HAVE_ASM_GOTO) && !__has_feature(memory_sanitizer)
# define ZEND_USE_ASM_ARITHMETIC 1
#else
# define ZEND_USE_ASM_ARITHMETIC 0
#endif
static zend_always_inline void fast_long_increment_function(zval *op1)
{
#if defined(HAVE_ASM_GOTO) && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
#if ZEND_USE_ASM_ARITHMETIC && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
__asm__ goto(
"addl $1,(%0)\n\t"
"jo %l1\n"
@@ -513,7 +519,7 @@ static zend_always_inline void fast_long_increment_function(zval *op1)
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MAX + 1.0);
#elif defined(HAVE_ASM_GOTO) && defined(__x86_64__)
#elif ZEND_USE_ASM_ARITHMETIC && defined(__x86_64__)
__asm__ goto(
"addq $1,(%0)\n\t"
"jo %l1\n"
@@ -524,7 +530,7 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MAX + 1.0);
#elif defined(HAVE_ASM_GOTO) && defined(__aarch64__)
#elif ZEND_USE_ASM_ARITHMETIC && defined(__aarch64__)
__asm__ goto (
"ldr x5, [%0]\n\t"
"adds x5, x5, 1\n\t"
@@ -565,7 +571,7 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL
static zend_always_inline void fast_long_decrement_function(zval *op1)
{
#if defined(HAVE_ASM_GOTO) && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
#if ZEND_USE_ASM_ARITHMETIC && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
__asm__ goto(
"subl $1,(%0)\n\t"
"jo %l1\n"
@@ -576,7 +582,7 @@ static zend_always_inline void fast_long_decrement_function(zval *op1)
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MIN - 1.0);
#elif defined(HAVE_ASM_GOTO) && defined(__x86_64__)
#elif ZEND_USE_ASM_ARITHMETIC && defined(__x86_64__)
__asm__ goto(
"subq $1,(%0)\n\t"
"jo %l1\n"
@@ -587,7 +593,7 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MIN - 1.0);
#elif defined(HAVE_ASM_GOTO) && defined(__aarch64__)
#elif ZEND_USE_ASM_ARITHMETIC && defined(__aarch64__)
__asm__ goto (
"ldr x5, [%0]\n\t"
"subs x5 ,x5, 1\n\t"
@@ -628,7 +634,7 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL
static zend_always_inline void fast_long_add_function(zval *result, zval *op1, zval *op2)
{
#if defined(HAVE_ASM_GOTO) && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
#if ZEND_USE_ASM_ARITHMETIC && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
__asm__ goto(
"movl (%1), %%eax\n\t"
"addl (%2), %%eax\n\t"
@@ -646,7 +652,7 @@ static zend_always_inline void fast_long_add_function(zval *result, zval *op1, z
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2));
#elif defined(HAVE_ASM_GOTO) && defined(__x86_64__)
#elif ZEND_USE_ASM_ARITHMETIC && defined(__x86_64__)
__asm__ goto(
"movq (%1), %%rax\n\t"
"addq (%2), %%rax\n\t"
@@ -664,7 +670,7 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2));
#elif defined(HAVE_ASM_GOTO) && defined(__aarch64__)
#elif ZEND_USE_ASM_ARITHMETIC && defined(__aarch64__)
__asm__ goto(
"ldr x5, [%1]\n\t"
"ldr x6, [%2]\n\t"
@@ -738,7 +744,7 @@ static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *o
static zend_always_inline void fast_long_sub_function(zval *result, zval *op1, zval *op2)
{
#if defined(HAVE_ASM_GOTO) && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
#if ZEND_USE_ASM_ARITHMETIC && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
__asm__ goto(
"movl (%1), %%eax\n\t"
"subl (%2), %%eax\n\t"
@@ -756,7 +762,7 @@ static zend_always_inline void fast_long_sub_function(zval *result, zval *op1, z
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2));
#elif defined(HAVE_ASM_GOTO) && defined(__x86_64__)
#elif ZEND_USE_ASM_ARITHMETIC && defined(__x86_64__)
__asm__ goto(
"movq (%1), %%rax\n\t"
"subq (%2), %%rax\n\t"
@@ -774,7 +780,7 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2));
#elif defined(HAVE_ASM_GOTO) && defined(__aarch64__)
#elif ZEND_USE_ASM_ARITHMETIC && defined(__aarch64__)
__asm__ goto(
"ldr x5, [%1]\n\t"
"ldr x6, [%2]\n\t"
+3 -3
View File
@@ -1113,11 +1113,11 @@ ZEND_VM_C_LABEL(assign_op_object):
do {
if (UNEXPECTED(Z_ISREF_P(zptr))) {
ref = Z_REF_P(zptr);
zptr = Z_REFVAL_P(zptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
zptr = Z_REFVAL_P(zptr);
}
if (OP2_TYPE == IS_CONST) {
@@ -1174,11 +1174,11 @@ ZEND_VM_HANDLER(29, ZEND_ASSIGN_STATIC_PROP_OP, ANY, ANY, OP)
do {
if (UNEXPECTED(Z_ISREF_P(prop))) {
ref = Z_REF_P(prop);
prop = Z_REFVAL_P(prop);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
prop = Z_REFVAL_P(prop);
}
if (UNEXPECTED(prop_info->type)) {
@@ -1302,11 +1302,11 @@ ZEND_VM_HANDLER(26, ZEND_ASSIGN_OP, VAR|CV, CONST|TMPVAR|CV, OP)
do {
if (UNEXPECTED(Z_TYPE_P(var_ptr) == IS_REFERENCE)) {
zend_reference *ref = Z_REF_P(var_ptr);
var_ptr = Z_REFVAL_P(var_ptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
var_ptr = Z_REFVAL_P(var_ptr);
}
zend_binary_op(var_ptr, var_ptr, value OPLINE_CC);
} while (0);
+16 -16
View File
@@ -816,11 +816,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_STATIC_PROP_OP_SPEC_HAN
do {
if (UNEXPECTED(Z_ISREF_P(prop))) {
ref = Z_REF_P(prop);
prop = Z_REFVAL_P(prop);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
prop = Z_REFVAL_P(prop);
}
if (UNEXPECTED(prop_info->type)) {
@@ -22087,11 +22087,11 @@ assign_op_object:
do {
if (UNEXPECTED(Z_ISREF_P(zptr))) {
ref = Z_REF_P(zptr);
zptr = Z_REFVAL_P(zptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
zptr = Z_REFVAL_P(zptr);
}
if (IS_CONST == IS_CONST) {
@@ -22227,11 +22227,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OP_SPEC_VAR_CONST_HANDL
do {
if (UNEXPECTED(Z_TYPE_P(var_ptr) == IS_REFERENCE)) {
zend_reference *ref = Z_REF_P(var_ptr);
var_ptr = Z_REFVAL_P(var_ptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
var_ptr = Z_REFVAL_P(var_ptr);
}
zend_binary_op(var_ptr, var_ptr, value OPLINE_CC);
} while (0);
@@ -24384,11 +24384,11 @@ assign_op_object:
do {
if (UNEXPECTED(Z_ISREF_P(zptr))) {
ref = Z_REF_P(zptr);
zptr = Z_REFVAL_P(zptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
zptr = Z_REFVAL_P(zptr);
}
if ((IS_TMP_VAR|IS_VAR) == IS_CONST) {
@@ -24525,11 +24525,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OP_SPEC_VAR_TMPVAR_HAND
do {
if (UNEXPECTED(Z_TYPE_P(var_ptr) == IS_REFERENCE)) {
zend_reference *ref = Z_REF_P(var_ptr);
var_ptr = Z_REFVAL_P(var_ptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
var_ptr = Z_REFVAL_P(var_ptr);
}
zend_binary_op(var_ptr, var_ptr, value OPLINE_CC);
} while (0);
@@ -28078,11 +28078,11 @@ assign_op_object:
do {
if (UNEXPECTED(Z_ISREF_P(zptr))) {
ref = Z_REF_P(zptr);
zptr = Z_REFVAL_P(zptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
zptr = Z_REFVAL_P(zptr);
}
if (IS_CV == IS_CONST) {
@@ -28218,11 +28218,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OP_SPEC_VAR_CV_HANDLER(
do {
if (UNEXPECTED(Z_TYPE_P(var_ptr) == IS_REFERENCE)) {
zend_reference *ref = Z_REF_P(var_ptr);
var_ptr = Z_REFVAL_P(var_ptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
var_ptr = Z_REFVAL_P(var_ptr);
}
zend_binary_op(var_ptr, var_ptr, value OPLINE_CC);
} while (0);
@@ -30556,11 +30556,11 @@ assign_op_object:
do {
if (UNEXPECTED(Z_ISREF_P(zptr))) {
ref = Z_REF_P(zptr);
zptr = Z_REFVAL_P(zptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
zptr = Z_REFVAL_P(zptr);
}
if (IS_CONST == IS_CONST) {
@@ -32395,11 +32395,11 @@ assign_op_object:
do {
if (UNEXPECTED(Z_ISREF_P(zptr))) {
ref = Z_REF_P(zptr);
zptr = Z_REFVAL_P(zptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
zptr = Z_REFVAL_P(zptr);
}
if ((IS_TMP_VAR|IS_VAR) == IS_CONST) {
@@ -34919,11 +34919,11 @@ assign_op_object:
do {
if (UNEXPECTED(Z_ISREF_P(zptr))) {
ref = Z_REF_P(zptr);
zptr = Z_REFVAL_P(zptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
zptr = Z_REFVAL_P(zptr);
}
if (IS_CV == IS_CONST) {
@@ -39034,11 +39034,11 @@ assign_op_object:
do {
if (UNEXPECTED(Z_ISREF_P(zptr))) {
ref = Z_REF_P(zptr);
zptr = Z_REFVAL_P(zptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
zptr = Z_REFVAL_P(zptr);
}
if (IS_CONST == IS_CONST) {
@@ -39174,11 +39174,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OP_SPEC_CV_CONST_HANDLE
do {
if (UNEXPECTED(Z_TYPE_P(var_ptr) == IS_REFERENCE)) {
zend_reference *ref = Z_REF_P(var_ptr);
var_ptr = Z_REFVAL_P(var_ptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
var_ptr = Z_REFVAL_P(var_ptr);
}
zend_binary_op(var_ptr, var_ptr, value OPLINE_CC);
} while (0);
@@ -42541,11 +42541,11 @@ assign_op_object:
do {
if (UNEXPECTED(Z_ISREF_P(zptr))) {
ref = Z_REF_P(zptr);
zptr = Z_REFVAL_P(zptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
zptr = Z_REFVAL_P(zptr);
}
if ((IS_TMP_VAR|IS_VAR) == IS_CONST) {
@@ -42682,11 +42682,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OP_SPEC_CV_TMPVAR_HANDL
do {
if (UNEXPECTED(Z_TYPE_P(var_ptr) == IS_REFERENCE)) {
zend_reference *ref = Z_REF_P(var_ptr);
var_ptr = Z_REFVAL_P(var_ptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
var_ptr = Z_REFVAL_P(var_ptr);
}
zend_binary_op(var_ptr, var_ptr, value OPLINE_CC);
} while (0);
@@ -47639,11 +47639,11 @@ assign_op_object:
do {
if (UNEXPECTED(Z_ISREF_P(zptr))) {
ref = Z_REF_P(zptr);
zptr = Z_REFVAL_P(zptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
zptr = Z_REFVAL_P(zptr);
}
if (IS_CV == IS_CONST) {
@@ -47779,11 +47779,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OP_SPEC_CV_CV_HANDLER(Z
do {
if (UNEXPECTED(Z_TYPE_P(var_ptr) == IS_REFERENCE)) {
zend_reference *ref = Z_REF_P(var_ptr);
var_ptr = Z_REFVAL_P(var_ptr);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
break;
}
var_ptr = Z_REFVAL_P(var_ptr);
}
zend_binary_op(var_ptr, var_ptr, value OPLINE_CC);
} while (0);
+1
View File
@@ -30,6 +30,7 @@ steps:
libreadline-dev \
libldap2-dev \
libsasl2-dev \
libsodium-dev \
libargon2-0-dev \
postgresql \
postgresql-contrib \
+1 -1
View File
@@ -16,7 +16,7 @@ jobs:
- job: ${{ parameters.configurationName }}
timeoutInMinutes: ${{ parameters.timeoutInMinutes }}
pool:
vmImage: 'ubuntu-16.04'
vmImage: 'ubuntu-18.04'
variables:
ubsan_options: 'print_stacktrace=1'
steps:
+1
View File
@@ -55,6 +55,7 @@ steps:
--with-ldap-sasl \
--with-password-argon2 \
--with-mhash \
--with-sodium \
--enable-werror \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d
+2 -1
View File
@@ -13,7 +13,7 @@ steps:
locales \
language-pack-de \
libglib2.0-dev:i386 \
openssl:i386 \
libssl-dev:i386 \
zlib1g-dev:i386 \
libxml2-dev:i386 \
libgmp-dev:i386 \
@@ -40,6 +40,7 @@ steps:
libreadline-dev:i386 \
libffi-dev:i386 \
libfreetype6-dev:i386 \
libsodium-dev:i386 \
postgresql \
postgresql-contrib \
${{ parameters.packages }}
+2 -1
View File
@@ -5,7 +5,7 @@ parameters:
jobs:
- job: ${{ parameters.configurationName }}
pool:
vmImage: 'ubuntu-16.04'
vmImage: 'ubuntu-18.04'
steps:
- template: apt.yml
- script: |
@@ -62,6 +62,7 @@ jobs:
--with-ffi \
--enable-zend-test \
--with-mhash \
--with-sodium \
--enable-werror \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d
+3 -2
View File
@@ -25,8 +25,8 @@ jobs:
--enable-fpm \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pgsql \
--with-pdo-pgsql \
--with-pgsql=/usr/local/opt/libpq \
--with-pdo-pgsql=/usr/local/opt/libpq \
--with-pdo-sqlite \
--without-pear \
--enable-gd \
@@ -65,6 +65,7 @@ jobs:
--enable-zend-test \
--enable-intl \
--with-mhash \
--with-sodium \
--enable-werror \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d
+3
View File
@@ -87,6 +87,7 @@ dnl
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
# Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
# Copyright (c) 2019 Enji Cooper <yaneurabeya@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
@@ -149,11 +150,13 @@ namespace cxx11
struct Base
{
virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
virtual ~Derived() override {}
virtual void f() override {}
};
+1 -15
View File
@@ -17,7 +17,7 @@ dnl Basic autoconf initialization, generation of config.nice.
dnl ----------------------------------------------------------------------------
AC_PREREQ([2.68])
AC_INIT([PHP],[7.4.3-dev],[https://bugs.php.net],[php],[https://www.php.net])
AC_INIT([PHP],[7.4.4],[https://bugs.php.net],[php],[https://www.php.net])
AC_CONFIG_SRCDIR([main/php_version.h])
AC_CONFIG_AUX_DIR([build])
AC_PRESERVE_HELP_ORDER
@@ -737,20 +737,6 @@ if test "$ac_cv__asm_goto" = yes; then
AC_DEFINE(HAVE_ASM_GOTO,1,[Define if asm goto support])
fi
dnl Check for variable length array support.
AC_CACHE_CHECK([whether compiler supports VLA], ac_cv__compiler_c99_vla,
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdlib.h>
int main(void) {
int i[rand()%10];
return 0;
}
]])],[ac_cv__compiler_c99_vla=yes], [ac_cv__compiler_c99_vla=no], [ac_cv__compiler_c99_vla=no])])
if test "$ac_cv__compiler_c99_vla" = yes; then
AC_DEFINE(HAVE_COMPILER_C99_VLA, 1, [Compiler supports VLA])
fi
dnl Check valgrind support.
PHP_ARG_WITH([valgrind],
[whether to enable valgrind support],
+13
View File
@@ -0,0 +1,13 @@
--TEST--
Bug #79247 (Garbage collecting variant objects segfaults)
--SKIPIF--
<?php
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
?>
--FILE--
<?php
$keep = new variant(null);
var_dump(gc_collect_cycles());
?>
--EXPECT--
int(0)
+5 -1
View File
@@ -341,11 +341,15 @@ PHP_MINIT_FUNCTION(com_dotnet)
#define COM_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_CS|CONST_PERSISTENT)
#define COM_ERR_CONST(x) { \
#if SIZEOF_ZEND_LONG == 8
# define COM_ERR_CONST(x) { \
zend_long __tmp; \
ULongToIntPtr(x, &__tmp); \
REGISTER_LONG_CONSTANT(#x, __tmp, CONST_CS|CONST_PERSISTENT); \
}
#else
# define COM_ERR_CONST COM_CONST
#endif
COM_CONST(CLSCTX_INPROC_SERVER);
COM_CONST(CLSCTX_INPROC_HANDLER);
+8 -1
View File
@@ -243,6 +243,13 @@ static HashTable *com_properties_get(zval *object)
return &zend_empty_array;
}
static HashTable *com_get_gc(zval *object, zval **table, int *n)
{
*table = NULL;
*n = 0;
return NULL;
}
static void function_dtor(zval *zv)
{
zend_internal_function *f = (zend_internal_function*)Z_PTR_P(zv);
@@ -573,7 +580,7 @@ zend_object_handlers php_com_object_handlers = {
com_object_count,
NULL, /* get_debug_info */
NULL, /* get_closure */
zend_std_get_gc, /* get_gc */
com_get_gc, /* get_gc */
};
void php_com_object_enable_event_sink(php_com_dotnet_object *obj, int enable)
+1 -1
View File
@@ -187,7 +187,7 @@ zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object, int b
SafeArrayGetUBound(V_ARRAY(&I->safe_array), 1, &I->sa_max);
/* pre-fetch the element */
if (php_com_safearray_get_elem(&I->safe_array, &I->v, bound)) {
if (I->sa_max >= bound && php_com_safearray_get_elem(&I->safe_array, &I->v, bound)) {
I->key = bound;
ZVAL_NULL(&ptr);
php_com_zval_from_variant(&ptr, &I->v, I->code_page);
+2 -11
View File
@@ -248,13 +248,6 @@ static struct IStreamVtbl php_istream_vtbl = {
static void istream_destructor(php_istream *stm)
{
if (stm->res) {
zend_resource *res = stm->res;
stm->res = NULL;
zend_list_delete(res);
return;
}
if (stm->refcount > 0) {
CoDisconnectObject((IUnknown*)stm, 0);
}
@@ -268,7 +261,6 @@ static void istream_destructor(php_istream *stm)
PHP_COM_DOTNET_API IStream *php_com_wrapper_export_stream(php_stream *stream)
{
php_istream *stm = (php_istream*)CoTaskMemAlloc(sizeof(*stm));
zval *tmp;
if (stm == NULL)
return NULL;
@@ -280,8 +272,7 @@ PHP_COM_DOTNET_API IStream *php_com_wrapper_export_stream(php_stream *stream)
stm->stream = stream;
GC_ADDREF(stream->res);
tmp = zend_list_insert(stm, le_istream);
stm->res = Z_RES_P(tmp);
stm->res = zend_register_resource(stm, le_istream);
return (IStream*)stm;
}
@@ -398,7 +389,7 @@ CPH_METHOD(SaveToFile)
RETURN_FALSE;
}
olefilename = php_com_string_to_olestring(filename, strlen(fullpath), helper->codepage);
olefilename = php_com_string_to_olestring(fullpath, strlen(fullpath), helper->codepage);
efree(fullpath);
}
res = IPersistFile_Save(helper->ipf, olefilename, remember);
+2 -2
View File
@@ -480,6 +480,7 @@ int php_com_process_typeinfo(ITypeInfo *typeinfo, HashTable *id_to_name, int pri
char *ansiname = NULL;
size_t ansinamelen;
int ret = 0;
DISPID lastid = 0; /* for props */
if (FAILED(ITypeInfo_GetTypeAttr(typeinfo, &attr))) {
return 0;
@@ -513,7 +514,6 @@ int php_com_process_typeinfo(ITypeInfo *typeinfo, HashTable *id_to_name, int pri
/* So we've got the dispatch interface; lets list the event methods */
for (i = 0; i < attr->cFuncs; i++) {
zval tmp;
DISPID lastid = 0; /* for props */
int isprop;
if (FAILED(ITypeInfo_GetFuncDesc(typeinfo, i, &func)))
@@ -626,8 +626,8 @@ int php_com_process_typeinfo(ITypeInfo *typeinfo, HashTable *id_to_name, int pri
ZVAL_STRINGL(&tmp, ansiname, ansinamelen);
zend_hash_index_update(id_to_name, func->memid, &tmp);
// TODO: avoid reallocation???
efree(ansiname);
}
efree(ansiname);
}
ITypeInfo_ReleaseFuncDesc(typeinfo, func);
}
+24
View File
@@ -0,0 +1,24 @@
--TEST--
Bug #66322 (COMPersistHelper::SaveToFile can save to wrong location)
--SKIPIF--
<?php
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
try {
new COM('Word.Application');
} catch (com_exception $ex) {
die('skip MS Word not available');
}
if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
?>
--FILE--
<?php
$w = new COM('Word.Application');
$doc = $w->Documents->Add();
$ph = new COMPersistHelper($doc);
$filename = __DIR__ . '\\..\\' . basename(__DIR__) . '\\66322.docx';
$ph->SaveToFile($filename);
var_dump(file_exists($filename));
$w->Quit();
?>
--EXPECT--
bool(true)
+3 -1
View File
@@ -2,7 +2,9 @@
Bug #73679 DOTNET read access violation using invalid codepage
--SKIPIF--
<?php
if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present";
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only");
?>
--FILE--
<?php
+22
View File
@@ -0,0 +1,22 @@
--TEST--
Bug #79242 (COM error constants don't match com_exception codes)
--SKIPIF--
<?php
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only");
?>
--FILE--
<?php
var_dump(
DISP_E_DIVBYZERO,
DISP_E_OVERFLOW,
DISP_E_BADINDEX,
MK_E_UNAVAILABLE
);
?>
--EXPECT--
int(-2147352558)
int(-2147352566)
int(-2147352565)
int(-2147221021)
+16
View File
@@ -0,0 +1,16 @@
--TEST--
Bug #79248 (Traversing empty VT_ARRAY throws com_exception)
--SKIPIF--
<?php
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
?>
--FILE--
<?php
$v = new variant([], VT_ARRAY);
foreach ($v as $el) {
var_dump($el);
}
echo "done\n";
?>
--EXPECT--
done
+20
View File
@@ -0,0 +1,20 @@
--TEST--
Bug #79299 (com_print_typeinfo prints duplicate variables)
--SKIPIF--
<?php
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
?>
--FILE--
<?php
$dict = new COM("Scripting.Dictionary");
ob_start();
com_print_typeinfo($dict);
$typeinfo = ob_get_clean();
preg_match_all('/\/\* DISPID=9 \*\//', $typeinfo, $matches);
var_dump($matches[0]);
?>
--EXPECT--
array(1) {
[0]=>
string(14) "/* DISPID=9 */"
}
+18
View File
@@ -0,0 +1,18 @@
--TEST--
Bug #79332 (php_istreams are never freed)
--SKIPIF--
<?php
if (!extension_loaded('com_dotnet')) die('com_dotnet extension not available');
?>
--FILE--
<?php
$ph = new COMPersistHelper(null);
try {
$ph->LoadFromStream(fopen(__FILE__, 'r'));
} catch (com_exception $ex) {
// use hard-coded message to avoid localization issues
echo "A com_exception has been thrown\n";
}
?>
--EXPECT--
A com_exception has been thrown
+116 -54
View File
@@ -1795,11 +1795,20 @@ static void curl_free_post(void **post)
}
/* }}} */
/* {{{ curl_free_stream
struct mime_data_cb_arg {
zend_string *filename;
php_stream *stream;
};
/* {{{ curl_free_cb_arg
*/
static void curl_free_stream(void **post)
static void curl_free_cb_arg(void **cb_arg_p)
{
php_stream_close((php_stream *)*post);
struct mime_data_cb_arg *cb_arg = (struct mime_data_cb_arg *) *cb_arg_p;
ZEND_ASSERT(cb_arg->stream == NULL);
zend_string_release(cb_arg->filename);
efree(cb_arg);
}
/* }}} */
@@ -1900,11 +1909,13 @@ php_curl *alloc_curl_handle()
zend_llist_init(&ch->to_free->str, sizeof(char *), (llist_dtor_func_t)curl_free_string, 0);
zend_llist_init(&ch->to_free->post, sizeof(struct HttpPost *), (llist_dtor_func_t)curl_free_post, 0);
zend_llist_init(&ch->to_free->stream, sizeof(php_stream *), (llist_dtor_func_t)curl_free_stream, 0);
zend_llist_init(&ch->to_free->stream, sizeof(struct mime_data_cb_arg *), (llist_dtor_func_t)curl_free_cb_arg, 0);
ch->to_free->slist = emalloc(sizeof(HashTable));
zend_hash_init(ch->to_free->slist, 4, NULL, curl_free_slist, 0);
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
ZVAL_UNDEF(&ch->postfields);
#endif
return ch;
}
/* }}} */
@@ -2094,47 +2105,21 @@ void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source)
(*source->clone)++;
}
/* {{{ proto resource curl_copy_handle(resource ch)
Copy a cURL handle along with all of it's preferences */
PHP_FUNCTION(curl_copy_handle)
{
CURL *cp;
zval *zid;
php_curl *ch, *dupch;
ZEND_PARSE_PARAMETERS_START(1,1)
Z_PARAM_RESOURCE(zid)
ZEND_PARSE_PARAMETERS_END();
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
RETURN_FALSE;
}
cp = curl_easy_duphandle(ch->cp);
if (!cp) {
php_error_docref(NULL, E_WARNING, "Cannot duplicate cURL handle");
RETURN_FALSE;
}
dupch = alloc_curl_handle();
dupch->cp = cp;
_php_setup_easy_copy_handlers(dupch, ch);
Z_ADDREF_P(zid);
ZVAL_RES(return_value, zend_register_resource(dupch, le_curl));
dupch->res = Z_RES_P(return_value);
}
/* }}} */
#if LIBCURL_VERSION_NUM >= 0x073800
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
static size_t read_cb(char *buffer, size_t size, size_t nitems, void *arg) /* {{{ */
{
php_stream *stream = (php_stream *) arg;
ssize_t numread = php_stream_read(stream, buffer, nitems * size);
struct mime_data_cb_arg *cb_arg = (struct mime_data_cb_arg *) arg;
ssize_t numread;
if (cb_arg->stream == NULL) {
if (!(cb_arg->stream = php_stream_open_wrapper(ZSTR_VAL(cb_arg->filename), "rb", IGNORE_PATH, NULL))) {
return CURL_READFUNC_ABORT;
}
}
numread = php_stream_read(cb_arg->stream, buffer, nitems * size);
if (numread < 0) {
php_stream_close(cb_arg->stream);
cb_arg->stream = NULL;
return CURL_READFUNC_ABORT;
}
return numread;
@@ -2143,13 +2128,25 @@ static size_t read_cb(char *buffer, size_t size, size_t nitems, void *arg) /* {{
static int seek_cb(void *arg, curl_off_t offset, int origin) /* {{{ */
{
php_stream *stream = (php_stream *) arg;
int res = php_stream_seek(stream, offset, origin);
struct mime_data_cb_arg *cb_arg = (struct mime_data_cb_arg *) arg;
int res;
if (res) {
if (cb_arg->stream == NULL) {
return CURL_SEEKFUNC_CANTSEEK;
}
return CURL_SEEKFUNC_OK;
res = php_stream_seek(cb_arg->stream, offset, origin);
return res == SUCCESS ? CURL_SEEKFUNC_OK : CURL_SEEKFUNC_CANTSEEK;
}
/* }}} */
static void free_cb(void *arg) /* {{{ */
{
struct mime_data_cb_arg *cb_arg = (struct mime_data_cb_arg *) arg;
if (cb_arg->stream != NULL) {
php_stream_close(cb_arg->stream);
cb_arg->stream = NULL;
}
}
/* }}} */
#endif
@@ -2160,7 +2157,7 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
zval *current;
HashTable *postfields;
zend_string *string_key;
zend_ulong num_key;
zend_ulong num_key;
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
curl_mime *mime = NULL;
curl_mimepart *part;
@@ -2202,7 +2199,11 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
zval *prop, rv;
char *type = NULL, *filename = NULL;
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
struct mime_data_cb_arg *cb_arg;
php_stream *stream;
php_stream_statbuf ssb;
size_t filesize = -1;
curl_seek_callback seekfunc = seek_cb;
#endif
prop = zend_read_property(curl_CURLFile_class, current, "name", sizeof("name")-1, 0, &rv);
@@ -2225,24 +2226,33 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
}
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
if (!(stream = php_stream_open_wrapper(ZSTR_VAL(postval), "rb", IGNORE_PATH, NULL))) {
zend_string_release_ex(string_key, 0);
return FAILURE;
zval_ptr_dtor(&ch->postfields);
ZVAL_COPY(&ch->postfields, zpostfields);
if ((stream = php_stream_open_wrapper(ZSTR_VAL(postval), "rb", STREAM_MUST_SEEK, NULL))) {
if (!stream->readfilters.head && !php_stream_stat(stream, &ssb)) {
filesize = ssb.sb.st_size;
}
} else {
seekfunc = NULL;
}
cb_arg = emalloc(sizeof *cb_arg);
cb_arg->filename = zend_string_copy(postval);
cb_arg->stream = stream;
part = curl_mime_addpart(mime);
if (part == NULL) {
php_stream_close(stream);
zend_string_release_ex(string_key, 0);
return FAILURE;
}
if ((form_error = curl_mime_name(part, ZSTR_VAL(string_key))) != CURLE_OK
|| (form_error = curl_mime_data_cb(part, -1, read_cb, seek_cb, NULL, stream)) != CURLE_OK
|| (form_error = curl_mime_data_cb(part, filesize, read_cb, seekfunc, free_cb, cb_arg)) != CURLE_OK
|| (form_error = curl_mime_filename(part, filename ? filename : ZSTR_VAL(postval))) != CURLE_OK
|| (form_error = curl_mime_type(part, type ? type : "application/octet-stream")) != CURLE_OK) {
php_stream_close(stream);
error = form_error;
}
zend_llist_add_element(&ch->to_free->stream, &stream);
zend_llist_add_element(&ch->to_free->stream, &cb_arg);
#else
form_error = curl_formadd(&first, &last,
CURLFORM_COPYNAME, ZSTR_VAL(string_key),
@@ -2310,11 +2320,60 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
zend_llist_add_element(&ch->to_free->post, &first);
error = curl_easy_setopt(ch->cp, CURLOPT_HTTPPOST, first);
#endif
SAVE_CURL_ERROR(ch, error);
return error == CURLE_OK ? SUCCESS : FAILURE;
}
/* }}} */
/* {{{ proto resource curl_copy_handle(resource ch)
Copy a cURL handle along with all of it's preferences */
PHP_FUNCTION(curl_copy_handle)
{
CURL *cp;
zval *zid;
php_curl *ch, *dupch;
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
zval *postfields;
#endif
ZEND_PARSE_PARAMETERS_START(1,1)
Z_PARAM_RESOURCE(zid)
ZEND_PARSE_PARAMETERS_END();
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
RETURN_FALSE;
}
cp = curl_easy_duphandle(ch->cp);
if (!cp) {
php_error_docref(NULL, E_WARNING, "Cannot duplicate cURL handle");
RETURN_FALSE;
}
dupch = alloc_curl_handle();
dupch->cp = cp;
_php_setup_easy_copy_handlers(dupch, ch);
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
postfields = &ch->postfields;
if (Z_TYPE_P(postfields) != IS_UNDEF) {
if (build_mime_structure_from_hash(dupch, postfields) != SUCCESS) {
_php_curl_close_ex(dupch);
php_error_docref(NULL, E_WARNING, "Cannot rebuild mime structure");
RETURN_FALSE;
}
}
#endif
Z_ADDREF_P(zid);
ZVAL_RES(return_value, zend_register_resource(dupch, le_curl));
dupch->res = Z_RES_P(return_value);
}
/* }}} */
static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ */
{
CURLcode error = CURLE_OK;
@@ -3613,6 +3672,9 @@ static void _php_curl_close_ex(php_curl *ch)
#endif
efree(ch->handlers);
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
zval_ptr_dtor(&ch->postfields);
#endif
efree(ch);
}
/* }}} */
+3
View File
@@ -183,6 +183,9 @@ typedef struct {
struct _php_curl_error err;
zend_bool in_callback;
uint32_t* clone;
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
zval postfields;
#endif
} php_curl;
#define CURLOPT_SAFE_UPLOAD -1
+4 -4
View File
@@ -38,7 +38,7 @@ var_dump(curl_exec($ch));
curl_close($ch);
?>
--EXPECTF--
string(%d) "curl_testdata1.txt|application/octet-stream"
string(%d) "curl_testdata1.txt|text/plain"
string(%d) "foo.txt|application/octet-stream"
string(%d) "foo.txt|text/plain"
string(%d) "curl_testdata1.txt|application/octet-stream|6"
string(%d) "curl_testdata1.txt|text/plain|6"
string(%d) "foo.txt|application/octet-stream|6"
string(%d) "foo.txt|text/plain|6"
+1 -1
View File
@@ -24,7 +24,7 @@ curl_close($ch);
===DONE===
--EXPECTF--
bool(true)
string(%d) "АБВ.txt|application/octet-stream"
string(%d) "АБВ.txt|application/octet-stream|5"
===DONE===
--CLEAN--
<?php
@@ -29,8 +29,8 @@ curl_close($ch2);
===DONE===
--EXPECTF--
bool(true)
string(%d) "АБВ.txt|application/octet-stream"
string(%d) "АБВ.txt|application/octet-stream"
string(%d) "АБВ.txt|application/octet-stream|5"
string(%d) "АБВ.txt|application/octet-stream|5"
===DONE===
--CLEAN--
<?php
@@ -0,0 +1,46 @@
--TEST--
curl_copy_handle() allows to post CURLFile multiple times with curl_multi_exec()
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
include 'server.inc';
$host = curl_cli_server_start();
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_SAFE_UPLOAD, 1);
curl_setopt($ch1, CURLOPT_URL, "{$host}/get.php?test=file");
// curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
$filename = __DIR__ . '/АБВ.txt';
file_put_contents($filename, "Test.");
$file = curl_file_create($filename);
$params = array('file' => $file);
var_dump(curl_setopt($ch1, CURLOPT_POSTFIELDS, $params));
$ch2 = curl_copy_handle($ch1);
$ch3 = curl_copy_handle($ch1);
$mh = curl_multi_init();
curl_multi_add_handle($mh, $ch1);
curl_multi_add_handle($mh, $ch2);
do {
$status = curl_multi_exec($mh, $active);
if ($active) {
curl_multi_select($mh);
}
} while ($active && $status == CURLM_OK);
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_remove_handle($mh, $ch3);
curl_multi_close($mh);
?>
===DONE===
--EXPECTF--
bool(true)
АБВ.txt|application/octet-stream|5АБВ.txt|application/octet-stream|5===DONE===
--CLEAN--
<?php
@unlink(__DIR__ . '/АБВ.txt');
?>
@@ -0,0 +1,52 @@
--TEST--
curl_copy_handle() allows to post CURLFile multiple times if postfields change
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
include 'server.inc';
$host = curl_cli_server_start();
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_SAFE_UPLOAD, 1);
curl_setopt($ch1, CURLOPT_URL, "{$host}/get.php?test=file");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
$filename = __DIR__ . '/abc.txt';
file_put_contents($filename, "Test.");
$file = curl_file_create($filename);
$params = array('file' => $file);
var_dump(curl_setopt($ch1, CURLOPT_POSTFIELDS, $params));
$ch2 = curl_copy_handle($ch1);
$filename = __DIR__ . '/def.txt';
file_put_contents($filename, "Other test.");
$file = curl_file_create($filename);
$params = array('file' => $file);
var_dump(curl_setopt($ch2, CURLOPT_POSTFIELDS, $params));
$ch3 = curl_copy_handle($ch2);
var_dump(curl_exec($ch1));
curl_close($ch1);
var_dump(curl_exec($ch2));
curl_close($ch2);
var_dump(curl_exec($ch3));
curl_close($ch3);
?>
===DONE===
--EXPECTF--
bool(true)
bool(true)
string(%d) "abc.txt|application/octet-stream|5"
string(%d) "def.txt|application/octet-stream|11"
string(%d) "def.txt|application/octet-stream|11"
===DONE===
--CLEAN--
<?php
@unlink(__DIR__ . '/abc.txt');
@unlink(__DIR__ . '/def.txt');
?>
+6 -6
View File
@@ -60,15 +60,15 @@ var_dump(curl_exec($ch));
curl_close($ch);
?>
--EXPECTF--
string(%d) "curl_testdata1.txt|application/octet-stream"
string(%d) "curl_testdata1.txt|text/plain"
string(%d) "foo.txt|application/octet-stream"
string(%d) "foo.txt|text/plain"
string(%d) "curl_testdata1.txt|application/octet-stream|6"
string(%d) "curl_testdata1.txt|text/plain|6"
string(%d) "foo.txt|application/octet-stream|6"
string(%d) "foo.txt|text/plain|6"
string(%d) "text/plain"
string(%d) "%s/curl_testdata1.txt"
string(%d) "curl_testdata1.txt|text/plain"
string(%d) "curl_testdata1.txt|text/plain|6"
string(%d) "foo.txt"
string(%d) "foo.txt|application/octet-stream"
string(%d) "foo.txt|application/octet-stream|6"
Warning: curl_setopt(): Disabling safe uploads is no longer supported in %s on line %d
string(0) ""
+1 -1
View File
@@ -24,5 +24,5 @@ curl_close($ch);
===DONE===
--EXPECT--
bool(true)
string(21) "i-love-php|text/plain"
string(24) "i-love-php|text/plain|11"
===DONE===
+1 -1
View File
@@ -28,7 +28,7 @@
break;
case 'file':
if (isset($_FILES['file'])) {
echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'] . '|' . $_FILES['file']['size'];
}
break;
case 'method':
+1 -1
View File
@@ -342,7 +342,7 @@ int dom_document_encoding_write(dom_object *obj, zval *newval)
return FAILURE;
}
handler = xmlFindCharEncodingHandler(Z_STRVAL_P(newval));
handler = xmlFindCharEncodingHandler(ZSTR_VAL(str));
if (handler != NULL) {
xmlCharEncCloseFunc(handler);
+3 -7
View File
@@ -431,13 +431,9 @@ int dom_node_child_nodes_read(dom_object *obj, zval *retval)
return FAILURE;
}
if (dom_node_children_valid(nodep) == FAILURE) {
ZVAL_NULL(retval);
} else {
php_dom_create_interator(retval, DOM_NODELIST);
intern = Z_DOMOBJ_P(retval);
dom_namednode_iter(obj, XML_ELEMENT_NODE, intern, NULL, NULL, NULL);
}
php_dom_create_interator(retval, DOM_NODELIST);
intern = Z_DOMOBJ_P(retval);
dom_namednode_iter(obj, XML_ELEMENT_NODE, intern, NULL, NULL, NULL);
return SUCCESS;
}
+2 -2
View File
@@ -50,7 +50,7 @@ object(DOMText)#%d (19) {
["parentNode"]=>
NULL
["childNodes"]=>
NULL
string(22) "(object value omitted)"
["firstChild"]=>
NULL
["lastChild"]=>
@@ -140,7 +140,7 @@ object(DOMText)#%d (19) {
["parentNode"]=>
NULL
["childNodes"]=>
NULL
string(22) "(object value omitted)"
["firstChild"]=>
NULL
["lastChild"]=>
+14
View File
@@ -0,0 +1,14 @@
--TEST--
Bug #77569 (Write Access Violation in DomImplementation)
--SKIPIF--
<?php
if (!extension_loaded('dom')) die('skip dom extension not available');
?>
--FILE--
<?php
$imp = new DOMImplementation;
$dom = $imp->createDocument("", "");
$dom->encoding = null;
?>
--EXPECTF--
Warning: main(): Invalid Document Encoding in %s on line %d
+17
View File
@@ -0,0 +1,17 @@
--TEST--
Bug #79271 (DOMDocumentType::$childNodes is NULL)
--SKIPIF--
<?php
if (!extension_loaded('dom')) die('skip dom extension not available');
?>
--FILE--
<?php
$dom = new DOMImplementation();
$type = $dom->createDocumentType('html');
var_dump($type->childNodes);
?>
--EXPECTF--
object(DOMNodeList)#%d (1) {
["length"]=>
int(0)
}
+6 -10
View File
@@ -725,18 +725,16 @@ PHP_FUNCTION(enchant_dict_quick_check)
PHP_ENCHANT_GET_DICT;
if (enchant_dict_check(pdict->pdict, word, wordlen) > 0) {
int n_sugg;
size_t n_sugg_st;
size_t n_sugg;
char **suggs;
if (!sugg && ZEND_NUM_ARGS() == 2) {
RETURN_FALSE;
}
suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg_st);
memcpy(&n_sugg, &n_sugg_st, sizeof(n_sugg));
suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg);
if (suggs && n_sugg) {
int i;
size_t i;
for (i = 0; i < n_sugg; i++) {
add_next_index_string(sugg, suggs[i]);
}
@@ -778,8 +776,7 @@ PHP_FUNCTION(enchant_dict_suggest)
size_t wordlen;
char **suggs;
enchant_dict *pdict;
int n_sugg;
size_t n_sugg_st;
size_t n_sugg;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &dict, &word, &wordlen) == FAILURE) {
RETURN_FALSE;
@@ -787,10 +784,9 @@ PHP_FUNCTION(enchant_dict_suggest)
PHP_ENCHANT_GET_DICT;
suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg_st);
memcpy(&n_sugg, &n_sugg_st, sizeof(n_sugg));
suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg);
if (suggs && n_sugg) {
int i;
size_t i;
array_init(return_value);
for (i = 0; i < n_sugg; i++) {
+6 -1
View File
@@ -3677,6 +3677,11 @@ static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf,
{
unsigned exif_value_2a, offset_of_ifd;
if (length < 2) {
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Missing TIFF alignment marker");
return;
}
/* set the thumbnail stuff to nothing so we can test to see if they get set up */
if (memcmp(CharBuf, "II", 2) == 0) {
ImageInfo->motorola_intel = 0;
@@ -3829,7 +3834,7 @@ static int exif_scan_JPEG_header(image_info_type *ImageInfo)
return FALSE;
}
sn = exif_file_sections_add(ImageInfo, marker, itemlen+1, NULL);
sn = exif_file_sections_add(ImageInfo, marker, itemlen, NULL);
Data = ImageInfo->file.list[sn].data;
/* Store first two pre-read bytes. */
+15
View File
@@ -0,0 +1,15 @@
--TEST--
Bug #79282: Use-of-uninitialized-value in exif
--FILE--
<?php
var_dump(exif_read_data('data://image/jpeg;base64,/9jhAAlFeGlmAAAg'));
?>
--EXPECTF--
Warning: exif_read_data(): Missing TIFF alignment marker in %s on line %d
Warning: exif_read_data(): File structure corrupted in %s on line %d
Warning: exif_read_data(): Invalid JPEG file in %s on line %d
bool(false)
+6
View File
@@ -3685,6 +3685,12 @@ ZEND_METHOD(FFI, new) /* {{{ */
}
}
if (type->size == 0) {
zend_throw_error(zend_ffi_exception_ce, "Cannot instantiate FFI\\CData of zero size");
zend_ffi_type_dtor(type_ptr);
return;
}
ptr = pemalloc(type->size, flags & ZEND_FFI_FLAG_PERSISTENT);
memset(ptr, 0, type->size);
+6 -2
View File
@@ -6,13 +6,17 @@ FFI 023: GCC struct extensions
ffi.enable=1
--FILE--
<?php
var_dump(FFI::sizeof(FFI::new("struct {}")));
try {
var_dump(FFI::sizeof(FFI::new("struct {}")));
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage() . "\n";
}
var_dump(FFI::sizeof(FFI::new("struct {int a}")));
var_dump(FFI::sizeof(FFI::new("struct {int a; int b}")));
?>
ok
--EXPECT--
int(0)
FFI\Exception: Cannot instantiate FFI\CData of zero size
int(4)
int(8)
ok
+1 -1
View File
@@ -81,7 +81,7 @@ FFI\ParserException: '[*]' not allowed in other than function prototype scope at
FFI\ParserException: '[*]' not allowed in other than function prototype scope at line 1
FFI\ParserException: '[*]' not allowed in other than function prototype scope at line 1
ok
int(0)
FFI\Exception: Cannot instantiate FFI\CData of zero size
FFI\ParserException: '[]' not allowed at line 1
FFI\ParserException: '[]' not allowed at line 1
ok
+1 -1
View File
@@ -26,4 +26,4 @@ bool(false)
Warning: FFI::isNull() expects parameter 1 to be FFI\CData, null given in %s045.php on line %d
NULL
FFI\Exception: FFI\Cdata is not a pointer
FFI\Exception: Cannot instantiate FFI\CData of zero size
+1
View File
@@ -4,4 +4,5 @@ if [[ ! -d libmagic.orig ]]; then
wget -O - ftp://ftp.astron.com/pub/file/file-$VERSION.tar.gz \
| tar -xz --strip-components=2 -C libmagic.orig file-$VERSION/src
fi
sed -e "s/X\.YY/${VERSION//.}/g" libmagic.orig/magic.h.in > libmagic.orig/magic.h
diff -u libmagic.orig libmagic | grep -v '^Only in' > libmagic.patch
+111 -61
View File
@@ -1,6 +1,6 @@
diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
--- libmagic.orig/apprentice.c 2019-02-20 03:35:27.000000000 +0100
+++ libmagic/apprentice.c 2019-06-29 22:00:36.200336685 +0200
+++ libmagic/apprentice.c 2020-02-27 11:45:38.445854000 +0100
@@ -29,6 +29,8 @@
* apprentice - make one pass through /etc/magic, learning its secrets.
*/
@@ -974,7 +974,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
}
diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c
--- libmagic.orig/ascmagic.c 2019-05-07 04:27:11.000000000 +0200
+++ libmagic/ascmagic.c 2019-06-29 20:07:54.070996657 +0200
+++ libmagic/ascmagic.c 2020-02-26 23:18:22.605400700 +0100
@@ -96,7 +96,7 @@
rv = file_ascmagic_with_encoding(ms, &bb,
ubuf, ulen, code, type, text);
@@ -1005,7 +1005,7 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c
}
diff -u libmagic.orig/buffer.c libmagic/buffer.c
--- libmagic.orig/buffer.c 2019-05-07 04:27:11.000000000 +0200
+++ libmagic/buffer.c 2019-06-29 22:07:44.306641133 +0200
+++ libmagic/buffer.c 2020-02-27 11:45:38.445854000 +0100
@@ -31,19 +31,23 @@
#endif /* lint */
@@ -1062,7 +1062,7 @@ diff -u libmagic.orig/buffer.c libmagic/buffer.c
diff -u libmagic.orig/cdf.c libmagic/cdf.c
--- libmagic.orig/cdf.c 2019-02-20 03:35:27.000000000 +0100
+++ libmagic/cdf.c 2019-06-29 20:07:54.074996599 +0200
+++ libmagic/cdf.c 2020-02-27 11:45:38.445854000 +0100
@@ -43,7 +43,17 @@
#include <err.h>
#endif
@@ -1264,7 +1264,28 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
*maxcount = 0;
*info = NULL;
return NULL;
@@ -1102,7 +1084,7 @@
@@ -1013,8 +995,9 @@
goto out;
}
nelements = CDF_GETUINT32(q, 1);
- if (nelements == 0) {
- DPRINTF(("CDF_VECTOR with nelements == 0\n"));
+ if (nelements > CDF_ELEMENT_LIMIT || nelements == 0) {
+ DPRINTF(("CDF_VECTOR with nelements == %"
+ SIZE_T_FORMAT "u\n", nelements));
goto out;
}
slen = 2;
@@ -1056,8 +1039,6 @@
goto out;
inp += nelem;
}
- DPRINTF(("nelements = %" SIZE_T_FORMAT "u\n",
- nelements));
for (j = 0; j < nelements && i < sh.sh_properties;
j++, i++)
{
@@ -1102,7 +1083,7 @@
}
return 0;
out:
@@ -1273,7 +1294,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
*info = NULL;
*count = 0;
*maxcount = 0;
@@ -1394,7 +1376,7 @@
@@ -1394,7 +1375,7 @@
cdf_directory_t *d;
char name[__arraycount(d->d_name)];
cdf_stream_t scn;
@@ -1282,7 +1303,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
static const char *types[] = { "empty", "user storage",
"user stream", "lockbytes", "property", "root storage" };
@@ -1436,7 +1418,7 @@
@@ -1436,7 +1417,7 @@
break;
}
cdf_dump_stream(&scn);
@@ -1291,7 +1312,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
break;
default:
break;
@@ -1449,7 +1431,7 @@
@@ -1449,7 +1430,7 @@
cdf_dump_property_info(const cdf_property_info_t *info, size_t count)
{
cdf_timestamp_t tp;
@@ -1300,7 +1321,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
char buf[64];
size_t i, j;
@@ -1534,7 +1516,7 @@
@@ -1534,7 +1515,7 @@
(void)fprintf(stderr, "Class %s\n", buf);
(void)fprintf(stderr, "Count %d\n", ssi.si_count);
cdf_dump_property_info(info, count);
@@ -1309,7 +1330,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
}
@@ -1555,7 +1537,7 @@
@@ -1555,7 +1536,7 @@
cdf_u16tos8(sbuf, ce[i].ce_namlen, ce[i].ce_name),
cdf_ctime(&ts.tv_sec, tbuf));
}
@@ -1320,7 +1341,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
#endif
diff -u libmagic.orig/cdf.h libmagic/cdf.h
--- libmagic.orig/cdf.h 2019-02-20 02:24:19.000000000 +0100
+++ libmagic/cdf.h 2019-06-29 20:07:54.074996599 +0200
+++ libmagic/cdf.h 2020-02-27 11:45:38.445854000 +0100
@@ -35,10 +35,10 @@
#ifndef _H_CDF_
#define _H_CDF_
@@ -1335,9 +1356,17 @@ diff -u libmagic.orig/cdf.h libmagic/cdf.h
#endif
#ifdef __DJGPP__
#define timespec timeval
@@ -48,6 +48,7 @@
typedef int32_t cdf_secid_t;
#define CDF_LOOP_LIMIT 10000
+#define CDF_ELEMENT_LIMIT 100000
#define CDF_SECID_NULL 0
#define CDF_SECID_FREE -1
diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c
--- libmagic.orig/cdf_time.c 2019-03-12 21:43:05.000000000 +0100
+++ libmagic/cdf_time.c 2019-06-29 20:07:54.074996599 +0200
+++ libmagic/cdf_time.c 2020-02-26 23:18:22.611402900 +0100
@@ -23,6 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
@@ -1366,7 +1395,7 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c
(void)snprintf(buf, 26, "*Bad* %#16.16" INT64_T_FORMAT "x\n",
diff -u libmagic.orig/compress.c libmagic/compress.c
--- libmagic.orig/compress.c 2019-05-07 04:27:11.000000000 +0200
+++ libmagic/compress.c 2019-06-29 20:07:54.078996542 +0200
+++ libmagic/compress.c 2020-02-27 11:45:38.445854000 +0100
@@ -45,13 +45,11 @@
#endif
#include <string.h>
@@ -1516,7 +1545,7 @@ diff -u libmagic.orig/compress.c libmagic/compress.c
+#endif
diff -u libmagic.orig/der.c libmagic/der.c
--- libmagic.orig/der.c 2019-02-20 03:35:27.000000000 +0100
+++ libmagic/der.c 2019-06-29 20:07:54.078996542 +0200
+++ libmagic/der.c 2020-02-27 11:45:38.445854000 +0100
@@ -51,7 +51,9 @@
#include "magic.h"
#include "der.h"
@@ -1546,7 +1575,7 @@ diff -u libmagic.orig/der.c libmagic/der.c
snprintf(buf + z, blen - z, "%.2x", d[i]);
diff -u libmagic.orig/elfclass.h libmagic/elfclass.h
--- libmagic.orig/elfclass.h 2019-02-20 02:30:19.000000000 +0100
+++ libmagic/elfclass.h 2019-06-29 20:07:54.078996542 +0200
+++ libmagic/elfclass.h 2020-02-26 23:18:22.613401700 +0100
@@ -41,7 +41,7 @@
return toomany(ms, "program headers", phnum);
flags |= FLAGS_IS_CORE;
@@ -1576,7 +1605,7 @@ diff -u libmagic.orig/elfclass.h libmagic/elfclass.h
CAST(int, elf_getu16(swap, elfhdr.e_shstrndx)),
diff -u libmagic.orig/encoding.c libmagic/encoding.c
--- libmagic.orig/encoding.c 2019-04-15 18:48:41.000000000 +0200
+++ libmagic/encoding.c 2019-06-29 20:07:54.078996542 +0200
+++ libmagic/encoding.c 2020-02-26 23:18:22.614402300 +0100
@@ -89,13 +89,13 @@
*code_mime = "binary";
@@ -1607,7 +1636,7 @@ diff -u libmagic.orig/encoding.c libmagic/encoding.c
}
diff -u libmagic.orig/file.h libmagic/file.h
--- libmagic.orig/file.h 2019-05-07 04:27:11.000000000 +0200
+++ libmagic/file.h 2019-06-29 20:32:19.553528888 +0200
+++ libmagic/file.h 2020-02-27 11:45:38.445854000 +0100
@@ -33,18 +33,9 @@
#ifndef __file_h__
#define __file_h__
@@ -1894,7 +1923,7 @@ diff -u libmagic.orig/file.h libmagic/file.h
#endif
diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
--- libmagic.orig/fsmagic.c 2019-05-07 04:26:48.000000000 +0200
+++ libmagic/fsmagic.c 2019-06-29 20:07:54.082996485 +0200
+++ libmagic/fsmagic.c 2020-02-26 23:18:22.616403500 +0100
@@ -66,26 +66,10 @@
# define minor(dev) ((dev) & 0xff)
#endif
@@ -2187,7 +2216,7 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
case S_IFSOCK:
diff -u libmagic.orig/funcs.c libmagic/funcs.c
--- libmagic.orig/funcs.c 2019-05-07 04:27:11.000000000 +0200
+++ libmagic/funcs.c 2019-06-29 20:07:54.082996485 +0200
+++ libmagic/funcs.c 2020-02-27 11:45:38.445854000 +0100
@@ -31,7 +31,6 @@
#endif /* lint */
@@ -2409,7 +2438,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
if (ms->c.li == NULL) {
file_oomem(ms, len);
return -1;
@@ -513,76 +520,41 @@
@@ -513,76 +520,38 @@
protected int
file_replace(struct magic_set *ms, const char *pat, const char *rep)
{
@@ -2437,11 +2466,9 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
+ zend_string *repl;
+ size_t rep_cnt = 0;
+
+ (void)setlocale(LC_CTYPE, "C");
+
+ opts |= PCRE2_MULTILINE;
+ convert_libmagic_pattern(&patt, (char*)pat, strlen(pat), opts);
+ if ((pce = pcre_get_compiled_regex_cache(Z_STR(patt))) == NULL) {
+ if ((pce = pcre_get_compiled_regex_cache_ex(Z_STR(patt), 0)) == NULL) {
+ zval_ptr_dtor(&patt);
+ rep_cnt = -1;
+ goto out;
@@ -2510,12 +2537,11 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
- file_magerror(ms, "regex error %d for `%s', (%s)", rc, rx->pat,
- errmsg);
+out:
+ (void)setlocale(LC_CTYPE, "");
+ return rep_cnt;
}
protected file_pushbuf_t *
@@ -593,7 +565,7 @@
@@ -593,7 +562,7 @@
if (ms->event_flags & EVENT_HAD_ERR)
return NULL;
@@ -2524,7 +2550,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
return NULL;
pb->buf = ms->o.buf;
@@ -611,8 +583,8 @@
@@ -611,8 +580,8 @@
char *rbuf;
if (ms->event_flags & EVENT_HAD_ERR) {
@@ -2535,7 +2561,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
return NULL;
}
@@ -621,7 +593,7 @@
@@ -621,7 +590,7 @@
ms->o.buf = pb->buf;
ms->offset = pb->offset;
@@ -2546,7 +2572,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
diff -u libmagic.orig/magic.c libmagic/magic.c
--- libmagic.orig/magic.c 2019-05-07 04:27:11.000000000 +0200
+++ libmagic/magic.c 2019-06-29 20:07:54.082996485 +0200
+++ libmagic/magic.c 2020-02-26 23:18:22.621402800 +0100
@@ -25,11 +25,6 @@
* SUCH DAMAGE.
*/
@@ -3010,8 +3036,8 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
public const char *
magic_error(struct magic_set *ms)
diff -u libmagic.orig/magic.h libmagic/magic.h
--- libmagic.orig/magic.h 2019-06-29 20:13:10.290924369 +0200
+++ libmagic/magic.h 2019-06-29 20:11:37.732033650 +0200
--- libmagic.orig/magic.h 2020-03-02 15:24:27.253951700 +0100
+++ libmagic/magic.h 2020-02-26 23:18:22.622402300 +0100
@@ -124,6 +124,7 @@
const char *magic_getpath(const char *, int);
@@ -3022,7 +3048,7 @@ diff -u libmagic.orig/magic.h libmagic/magic.h
diff -u libmagic.orig/print.c libmagic/print.c
--- libmagic.orig/print.c 2019-03-12 21:43:05.000000000 +0100
+++ libmagic/print.c 2019-06-29 20:07:54.082996485 +0200
+++ libmagic/print.c 2020-02-26 23:18:22.625401800 +0100
@@ -28,6 +28,7 @@
/*
* print.c - debugging printout routines
@@ -3096,7 +3122,7 @@ diff -u libmagic.orig/print.c libmagic/print.c
goto out;
diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
--- libmagic.orig/readcdf.c 2019-03-12 21:43:05.000000000 +0100
+++ libmagic/readcdf.c 2019-06-29 22:10:43.100179773 +0200
+++ libmagic/readcdf.c 2020-02-27 11:45:38.445854000 +0100
@@ -31,7 +31,11 @@
#include <assert.h>
@@ -3120,12 +3146,13 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
return NULL;
}
@@ -112,30 +112,14 @@
@@ -112,30 +112,24 @@
{
size_t i;
const char *rv = NULL;
-#ifdef USE_C_LOCALE
- locale_t old_lc_ctype, c_lc_ctype;
+ char *vbuf_lower;
- c_lc_ctype = newlocale(LC_CTYPE_MASK, "C", 0);
- assert(c_lc_ctype != NULL);
@@ -3134,9 +3161,18 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
-#else
- char *old_lc_ctype = setlocale(LC_CTYPE, "C");
-#endif
+ (void)setlocale(LC_CTYPE, "C");
for (i = 0; nv[i].pattern != NULL; i++)
if (strcasestr(vbuf, nv[i].pattern) != NULL) {
- for (i = 0; nv[i].pattern != NULL; i++)
- if (strcasestr(vbuf, nv[i].pattern) != NULL) {
+ vbuf_lower = zend_str_tolower_dup(vbuf, strlen(vbuf));
+ for (i = 0; nv[i].pattern != NULL; i++) {
+ char *pattern_lower;
+ int found;
+
+ pattern_lower = zend_str_tolower_dup(nv[i].pattern, strlen(nv[i].pattern));
+ found = (strstr(vbuf_lower, pattern_lower) != NULL);
+ efree(pattern_lower);
+
+ if (found) {
rv = nv[i].mime;
break;
}
@@ -3149,11 +3185,13 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
-#else
- setlocale(LC_CTYPE, old_lc_ctype);
-#endif
+ (void)setlocale(LC_CTYPE, "");
+ }
+
+ efree(vbuf_lower);
return rv;
}
@@ -151,7 +135,9 @@
@@ -151,7 +145,9 @@
const char *s, *e;
int len;
@@ -3164,7 +3202,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
str = cdf_clsid_to_mime(root_storage->d_storage_uuid,
clsid2mime);
@@ -277,10 +263,10 @@
@@ -277,10 +273,10 @@
if (file_printf(ms, "%s%s",
cdf_u16tos8(buf, ce[i].ce_namlen, ce[i].ce_name),
i == cat->cat_num - 1 ? "]" : ", ") == -1) {
@@ -3177,7 +3215,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
} else if (ms->flags & MAGIC_MIME_TYPE) {
if (file_printf(ms, "application/CDFV2") == -1)
return -1;
@@ -341,7 +327,7 @@
@@ -341,7 +337,7 @@
}
m = cdf_file_property_info(ms, info, count, root_storage);
@@ -3186,7 +3224,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
return m == -1 ? -2 : m;
}
@@ -651,11 +637,11 @@
@@ -651,11 +647,11 @@
cdf_zero_stream(&scn);
cdf_zero_stream(&sst);
out3:
@@ -3203,7 +3241,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
if (i != -1)
diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
--- libmagic.orig/softmagic.c 2019-05-17 04:24:59.000000000 +0200
+++ libmagic/softmagic.c 2019-06-29 20:07:54.086996427 +0200
+++ libmagic/softmagic.c 2020-03-02 15:23:10.176763300 +0100
@@ -43,6 +43,10 @@
#include <time.h>
#include "der.h"
@@ -3247,14 +3285,13 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
#define FLT (STRING_BINTEST | STRING_TEXTTEST)
((text && (m->str_flags & FLT) == STRING_BINTEST) ||
(!text && (m->str_flags & FLT) == STRING_TEXTTEST))) ||
@@ -463,45 +469,30 @@
@@ -463,45 +469,28 @@
private int
check_fmt(struct magic_set *ms, const char *fmt)
{
- file_regex_t rx;
- int rc, rv = -1;
+ pcre2_code *pce;
+ uint32_t capture_count;
+ pcre_cache_entry *pce;
+ int rv = -1;
+ zend_string *pattern;
@@ -3264,22 +3301,21 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
- rc = file_regcomp(&rx, "%[-0-9\\.]*s", REG_EXTENDED|REG_NOSUB);
- if (rc) {
- file_regerror(&rx, rc, ms);
+ (void)setlocale(LC_CTYPE, "C");
+ pattern = zend_string_init("~%[-0-9\\.]*s~", sizeof("~%[-0-9\\.]*s~") - 1, 0);
+ if ((pce = pcre_get_compiled_regex(pattern, &capture_count)) == NULL) {
+ if ((pce = pcre_get_compiled_regex_cache_ex(pattern, 0)) == NULL) {
+ rv = -1;
} else {
- rc = file_regexec(&rx, fmt, 0, 0, 0);
- rv = !rc;
+ pcre2_match_data *match_data = php_pcre_create_match_data(capture_count, pce);
+ pcre2_code *re = php_pcre_pce_re(pce);
+ pcre2_match_data *match_data = php_pcre_create_match_data(0, re);
+ if (match_data) {
+ rv = pcre2_match(pce, (PCRE2_SPTR)fmt, strlen(fmt), 0, 0, match_data, php_pcre_mctx()) > 0;
+ rv = pcre2_match(re, (PCRE2_SPTR)fmt, strlen(fmt), 0, 0, match_data, php_pcre_mctx()) > 0;
+ php_pcre_free_match_data(match_data);
+ }
}
- file_regfree(&rx);
+ zend_string_release_ex(pattern, 0);
+ (void)setlocale(LC_CTYPE, "");
+ zend_string_release(pattern);
return rv;
}
@@ -3308,7 +3344,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
static int
varexpand(struct magic_set *ms, char *buf, size_t len, const char *str)
{
@@ -796,15 +787,11 @@
@@ -796,15 +785,11 @@
char *cp;
int rval;
@@ -3327,7 +3363,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
if (rval == -1)
return -1;
@@ -1555,9 +1542,6 @@
@@ -1555,9 +1540,6 @@
*indir_count, *name_count);
mdebug(offset, RCAST(char *, RCAST(void *, p)),
sizeof(union VALUETYPE));
@@ -3337,7 +3373,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
}
if (m->flag & INDIR) {
@@ -1685,7 +1669,7 @@
@@ -1685,7 +1667,7 @@
offset = do_ops(m, SEXT(sgn,64,BE64(p)), off);
break;
default:
@@ -3346,7 +3382,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
}
if (m->flag & INDIROFFADD) {
@@ -1706,9 +1690,6 @@
@@ -1706,9 +1688,6 @@
if ((ms->flags & MAGIC_DEBUG) != 0) {
mdebug(offset, RCAST(char *, RCAST(void *, p)),
sizeof(union VALUETYPE));
@@ -3356,7 +3392,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
}
}
@@ -1792,17 +1773,16 @@
@@ -1792,17 +1771,16 @@
if (rv == 1) {
if ((ms->flags & MAGIC_NODESC) == 0 &&
@@ -3378,18 +3414,32 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
return rv;
case FILE_USE:
@@ -1926,6 +1906,47 @@
@@ -1926,6 +1904,61 @@
return file_strncmp(a, b, len, flags);
}
+public void
+convert_libmagic_pattern(zval *pattern, char *val, size_t len, uint32_t options)
+{
+ int i, j=0;
+ int i, j;
+ zend_string *t;
+
+ t = zend_string_alloc(len * 2 + 4, 0);
+ for (i = j = 0; i < len; i++) {
+ switch (val[i]) {
+ case '~':
+ j += 2;
+ break;
+ case '\0':
+ j += 4;
+ break;
+ default:
+ j++;
+ break;
+ }
+ }
+ t = zend_string_alloc(j + 4, 0);
+
+ j = 0;
+ ZSTR_VAL(t)[j++] = '~';
+
+ for (i = 0; i < len; i++, j++) {
@@ -3426,7 +3476,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
private int
magiccheck(struct magic_set *ms, struct magic *m)
{
@@ -2104,65 +2125,77 @@
@@ -2104,65 +2137,77 @@
break;
}
case FILE_REGEX: {
@@ -3558,7 +3608,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
case FILE_INDIRECT:
diff -u libmagic.orig/strcasestr.c libmagic/strcasestr.c
--- libmagic.orig/strcasestr.c 2014-09-11 17:05:33.000000000 +0200
+++ libmagic/strcasestr.c 2019-06-29 20:07:54.086996427 +0200
+++ libmagic/strcasestr.c 2019-11-29 08:49:38.434136600 +0100
@@ -39,6 +39,8 @@
#include "file.h"
+16 -2
View File
@@ -1907,11 +1907,25 @@ file_strncmp16(const char *a, const char *b, size_t len, uint32_t flags)
public void
convert_libmagic_pattern(zval *pattern, char *val, size_t len, uint32_t options)
{
int i, j=0;
int i, j;
zend_string *t;
t = zend_string_alloc(len * 2 + 4, 0);
for (i = j = 0; i < len; i++) {
switch (val[i]) {
case '~':
j += 2;
break;
case '\0':
j += 4;
break;
default:
j++;
break;
}
}
t = zend_string_alloc(j + 4, 0);
j = 0;
ZSTR_VAL(t)[j++] = '~';
for (i = 0; i < len; i++, j++) {
+22
View File
@@ -0,0 +1,22 @@
--TEST--
Bug #79283 (Segfault in libmagic patch contains a buffer overflow)
--SKIPIF--
<?php
if (!extension_loaded('fileinfo')) die('skip fileinfo extension not available');
?>
--FILE--
<?php
$magic_file = __DIR__ . '/bug79283.db';
file_put_contents($magic_file, "
0 regex \\0\\0\\0\\0 Test
");
$finfo = new finfo(FILEINFO_NONE, $magic_file);
var_dump($finfo->buffer("buffer\n"));
?>
--CLEAN--
<?php
unlink(__DIR__ . '/bug79283.db');
?>
--EXPECT--
string(10) "ASCII text"
+2 -5
View File
@@ -63,9 +63,6 @@ static inline void php_converter_throw_failure(php_converter_object *objval, UEr
/* {{{ php_converter_default_callback */
static void php_converter_default_callback(zval *return_value, zval *zobj, zend_long reason, zval *error) {
ZVAL_DEREF(error);
zval_ptr_dtor(error);
ZVAL_LONG(error, U_ZERO_ERROR);
/* Basic functionality so children can call parent::toUCallback() */
switch (reason) {
case UCNV_UNASSIGNED:
@@ -81,7 +78,7 @@ static void php_converter_default_callback(zval *return_value, zval *zobj, zend_
chars[0] = 0x1A;
chars[1] = 0;
chars_len = 1;
ZVAL_LONG(error, U_INVALID_STATE_ERROR);
ZEND_TRY_ASSIGN_REF_LONG(error, U_INVALID_STATE_ERROR);
RETVAL_STRINGL(chars, chars_len);
return;
}
@@ -99,8 +96,8 @@ static void php_converter_default_callback(zval *return_value, zval *zobj, zend_
chars[0] = 0x1A;
chars[1] = 0;
chars_len = 1;
ZVAL_LONG(error, uerror);
}
ZEND_TRY_ASSIGN_REF_LONG(error, uerror);
RETVAL_STRINGL(chars, chars_len);
}
}
+1 -1
View File
@@ -315,7 +315,7 @@ static int convert_case_filter(int c, void *void_data)
/* Handle invalid characters early, as we assign special meaning to
* codepoints above 0xffffff. */
if (UNEXPECTED(c > 0xffffff)) {
if (UNEXPECTED((unsigned) c > 0xffffff)) {
(*data->next_filter->filter_function)(c, data->next_filter);
return 0;
}
+14
View File
@@ -0,0 +1,14 @@
--TEST--
Bug #79371 (mb_strtolower (UTF-32LE): stack-buffer-overflow)
--SKIPIF--
<?php
if (!extension_loaded('mbstring')) die('skip mbstring extension not available');
?>
--FILE--
<?php
$bytes = array(0xef, 0xbf, 0xbd, 0xef);
$str = implode(array_map("chr", $bytes));
var_dump(bin2hex(mb_strtolower($str, "UTF-32LE")));
?>
--EXPECT--
string(8) "3f000000"
+1 -1
View File
@@ -93,7 +93,7 @@ static int driver_embedded_read(mysqli_object *obj, zval *retval, zend_bool quie
/* {{{ property driver_client_version_read */
static int driver_client_version_read(mysqli_object *obj, zval *retval, zend_bool quiet)
{
ZVAL_LONG(retval, MYSQL_VERSION_ID);
ZVAL_LONG(retval, mysql_get_client_version());
return SUCCESS;
}
+3
View File
@@ -36,6 +36,9 @@ if (PHP_MYSQLND != "no") {
{
AC_DEFINE("MYSQLND_COMPRESSION_ENABLED", 1, "Compression support");
AC_DEFINE("MYSQLND_SSL_SUPPORTED", 1, "SSL support");
if (CHECK_LIB("crypt32.lib", "mysqlnd")) {
AC_DEFINE("MYSQLND_HAVE_SSL", 1, "Extended SSL support");
}
}
PHP_INSTALL_HEADERS("", "ext/mysqlnd");
}
+212 -61
View File
@@ -694,20 +694,146 @@ mysqlnd_xor_string(char * dst, const size_t dst_len, const char * xor_str, const
}
}
#ifndef PHP_WIN32
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/err.h>
typedef RSA * mysqlnd_rsa_t;
/* {{{ mysqlnd_sha256_get_rsa_from_pem */
static mysqlnd_rsa_t
mysqlnd_sha256_get_rsa_from_pem(const char *buf, size_t len)
{
BIO * bio = BIO_new_mem_buf(buf, len);
RSA * ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL);
BIO_free(bio);
return ret;
}
/* }}} */
/* {{{ mysqlnd_sha256_public_encrypt */
static zend_uchar *
mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size_t passwd_len, size_t * auth_data_len, char *xor_str)
{
zend_uchar * ret = NULL;
size_t server_public_key_len = (size_t) RSA_size(server_public_key);
DBG_ENTER("mysqlnd_sha256_public_encrypt");
/*
Because RSA_PKCS1_OAEP_PADDING is used there is a restriction on the passwd_len.
RSA_PKCS1_OAEP_PADDING is recommended for new applications. See more here:
http://www.openssl.org/docs/crypto/RSA_public_encrypt.html
*/
if (server_public_key_len <= passwd_len + 41) {
/* password message is to long */
SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
DBG_ERR("password is too long");
DBG_RETURN(NULL);
}
*auth_data_len = server_public_key_len;
ret = malloc(*auth_data_len);
RSA_public_encrypt(passwd_len + 1, (zend_uchar *) xor_str, ret, server_public_key, RSA_PKCS1_OAEP_PADDING);
RSA_free(server_public_key);
DBG_RETURN(ret);
}
/* }}} */
#else
#include <wincrypt.h>
#include <bcrypt.h>
typedef HANDLE mysqlnd_rsa_t;
/* {{{ mysqlnd_sha256_get_rsa_from_pem */
static mysqlnd_rsa_t
mysqlnd_sha256_get_rsa_from_pem(const char *buf, size_t len)
{
BCRYPT_KEY_HANDLE ret = 0;
LPCSTR der_buf = NULL;
DWORD der_len;
CERT_PUBLIC_KEY_INFO *key_info = NULL;
DWORD key_info_len;
ALLOCA_FLAG(use_heap);
if (!CryptStringToBinaryA(buf, len, CRYPT_STRING_BASE64HEADER, NULL, &der_len, NULL, NULL)) {
goto finish;
}
der_buf = do_alloca(der_len, use_heap);
if (!CryptStringToBinaryA(buf, len, CRYPT_STRING_BASE64HEADER, der_buf, &der_len, NULL, NULL)) {
goto finish;
}
if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO, der_buf, der_len, CRYPT_ENCODE_ALLOC_FLAG, NULL, &key_info, &key_info_len)) {
goto finish;
}
if (!CryptImportPublicKeyInfoEx2(X509_ASN_ENCODING, key_info, CRYPT_OID_INFO_PUBKEY_ENCRYPT_KEY_FLAG, NULL, &ret)) {
goto finish;
}
finish:
if (key_info) {
LocalFree(key_info);
}
if (der_buf) {
free_alloca(der_buf, use_heap);
}
return (mysqlnd_rsa_t) ret;
}
/* }}} */
/* {{{ mysqlnd_sha256_public_encrypt */
static zend_uchar *
mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size_t passwd_len, size_t * auth_data_len, char *xor_str)
{
zend_uchar * ret = NULL;
DWORD server_public_key_len = passwd_len;
BCRYPT_OAEP_PADDING_INFO padding_info;
DBG_ENTER("mysqlnd_sha256_public_encrypt");
ZeroMemory(&padding_info, sizeof padding_info);
padding_info.pszAlgId = BCRYPT_SHA1_ALGORITHM;
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
NULL, 0, NULL, 0, &server_public_key_len, BCRYPT_PAD_OAEP)) {
DBG_RETURN(0);
}
/*
Because RSA_PKCS1_OAEP_PADDING is used there is a restriction on the passwd_len.
RSA_PKCS1_OAEP_PADDING is recommended for new applications. See more here:
http://www.openssl.org/docs/crypto/RSA_public_encrypt.html
*/
if ((size_t) server_public_key_len <= passwd_len + 41) {
/* password message is to long */
SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
DBG_ERR("password is too long");
DBG_RETURN(0);
}
*auth_data_len = server_public_key_len;
ret = malloc(*auth_data_len);
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
NULL, 0, ret, server_public_key_len, &server_public_key_len, BCRYPT_PAD_OAEP)) {
DBG_RETURN(0);
}
BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key);
DBG_RETURN(ret);
}
/* }}} */
#endif
/* {{{ mysqlnd_sha256_get_rsa_key */
static RSA *
static mysqlnd_rsa_t
mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn,
const MYSQLND_SESSION_OPTIONS * const session_options,
const MYSQLND_PFC_DATA * const pfc_data
)
{
RSA * ret = NULL;
mysqlnd_rsa_t ret = NULL;
const char * fname = (pfc_data->sha256_server_public_key && pfc_data->sha256_server_public_key[0] != '\0')?
pfc_data->sha256_server_public_key:
MYSQLND_G(sha256_server_public_key);
@@ -739,11 +865,7 @@ mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn,
}
DBG_INF_FMT("Public key(%d):\n%s", pk_resp_packet.public_key_len, pk_resp_packet.public_key);
/* now extract the public key */
{
BIO * bio = BIO_new_mem_buf(pk_resp_packet.public_key, pk_resp_packet.public_key_len);
ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL);
BIO_free(bio);
}
ret = mysqlnd_sha256_get_rsa_from_pem((const char *) pk_resp_packet.public_key, pk_resp_packet.public_key_len);
} while (0);
PACKET_FREE(&pk_req_packet);
PACKET_FREE(&pk_resp_packet);
@@ -762,9 +884,7 @@ mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn,
if (stream) {
if ((key_str = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0)) != NULL) {
BIO * bio = BIO_new_mem_buf(ZSTR_VAL(key_str), ZSTR_LEN(key_str));
ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL);
BIO_free(bio);
ret = mysqlnd_sha256_get_rsa_from_pem(ZSTR_VAL(key_str), ZSTR_LEN(key_str));
DBG_INF("Successfully loaded");
DBG_INF_FMT("Public key:%*.s", ZSTR_LEN(key_str), ZSTR_VAL(key_str));
zend_string_release_ex(key_str, 0);
@@ -788,7 +908,7 @@ mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
const zend_ulong mysql_flags
)
{
RSA * server_public_key;
mysqlnd_rsa_t server_public_key;
zend_uchar * ret = NULL;
DBG_ENTER("mysqlnd_sha256_auth_get_auth_data");
DBG_INF_FMT("salt(%d)=[%.*s]", auth_plugin_data_len, auth_plugin_data_len, auth_plugin_data);
@@ -805,29 +925,13 @@ mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
server_public_key = mysqlnd_sha256_get_rsa_key(conn, session_options, pfc_data);
if (server_public_key) {
int server_public_key_len;
char xor_str[passwd_len + 1];
ALLOCA_FLAG(use_heap);
char *xor_str = do_alloca(passwd_len + 1, use_heap);
memcpy(xor_str, passwd, passwd_len);
xor_str[passwd_len] = '\0';
mysqlnd_xor_string(xor_str, passwd_len, (char *) auth_plugin_data, auth_plugin_data_len);
server_public_key_len = RSA_size(server_public_key);
/*
Because RSA_PKCS1_OAEP_PADDING is used there is a restriction on the passwd_len.
RSA_PKCS1_OAEP_PADDING is recommended for new applications. See more here:
http://www.openssl.org/docs/crypto/RSA_public_encrypt.html
*/
if ((size_t) server_public_key_len - 41 <= passwd_len) {
/* password message is to long */
SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
DBG_ERR("password is too long");
DBG_RETURN(NULL);
}
*auth_data_len = server_public_key_len;
ret = malloc(*auth_data_len);
RSA_public_encrypt(passwd_len + 1, (zend_uchar *) xor_str, ret, server_public_key, RSA_PKCS1_OAEP_PADDING);
RSA_free(server_public_key);
ret = mysqlnd_sha256_public_encrypt(conn, server_public_key, passwd_len, auth_data_len, xor_str);
free_alloca(xor_str, use_heap);
}
}
@@ -898,6 +1002,73 @@ void php_mysqlnd_scramble_sha2(zend_uchar * const buffer, const zend_uchar * con
}
/* }}} */
#ifndef PHP_WIN32
/* {{{ mysqlnd_caching_sha2_public_encrypt */
static size_t
mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size_t passwd_len, unsigned char **crypted, char *xor_str)
{
size_t server_public_key_len = (size_t) RSA_size(server_public_key);
DBG_ENTER("mysqlnd_caching_sha2_public_encrypt");
/*
Because RSA_PKCS1_OAEP_PADDING is used there is a restriction on the passwd_len.
RSA_PKCS1_OAEP_PADDING is recommended for new applications. See more here:
http://www.openssl.org/docs/crypto/RSA_public_encrypt.html
*/
if (server_public_key_len <= passwd_len + 41) {
/* password message is to long */
SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
DBG_ERR("password is too long");
DBG_RETURN(0);
}
*crypted = emalloc(server_public_key_len);
RSA_public_encrypt(passwd_len + 1, (zend_uchar *) xor_str, *crypted, server_public_key, RSA_PKCS1_OAEP_PADDING);
DBG_RETURN(server_public_key_len);
}
/* }}} */
#else
/* {{{ mysqlnd_caching_sha2_public_encrypt */
static size_t
mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size_t passwd_len, unsigned char **crypted, char *xor_str)
{
DWORD server_public_key_len = passwd_len;
BCRYPT_OAEP_PADDING_INFO padding_info;
DBG_ENTER("mysqlnd_caching_sha2_public_encrypt");
ZeroMemory(&padding_info, sizeof padding_info);
padding_info.pszAlgId = BCRYPT_SHA1_ALGORITHM;
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
NULL, 0, NULL, 0, &server_public_key_len, BCRYPT_PAD_OAEP)) {
DBG_RETURN(0);
}
/*
Because RSA_PKCS1_OAEP_PADDING is used there is a restriction on the passwd_len.
RSA_PKCS1_OAEP_PADDING is recommended for new applications. See more here:
http://www.openssl.org/docs/crypto/RSA_public_encrypt.html
*/
if ((size_t) server_public_key_len <= passwd_len + 41) {
/* password message is to long */
SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
DBG_ERR("password is too long");
DBG_RETURN(0);
}
*crypted = emalloc(server_public_key_len);
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
NULL, 0, *crypted, server_public_key_len, &server_public_key_len, BCRYPT_PAD_OAEP)) {
DBG_RETURN(0);
}
DBG_RETURN(server_public_key_len);
}
/* }}} */
#endif
/* {{{ mysqlnd_native_auth_get_auth_data */
static zend_uchar *
@@ -935,10 +1106,10 @@ mysqlnd_caching_sha2_get_auth_data(struct st_mysqlnd_authentication_plugin * sel
}
/* }}} */
static RSA *
static mysqlnd_rsa_t
mysqlnd_caching_sha2_get_key(MYSQLND_CONN_DATA *conn)
{
RSA * ret = NULL;
mysqlnd_rsa_t ret = NULL;
const MYSQLND_PFC_DATA * const pfc_data = conn->protocol_frame_codec->data;
const char * fname = (pfc_data->sha256_server_public_key && pfc_data->sha256_server_public_key[0] != '\0')?
pfc_data->sha256_server_public_key:
@@ -972,11 +1143,7 @@ mysqlnd_caching_sha2_get_key(MYSQLND_CONN_DATA *conn)
}
DBG_INF_FMT("Public key(%d):\n%s", pk_resp_packet.public_key_len, pk_resp_packet.public_key);
/* now extract the public key */
{
BIO * bio = BIO_new_mem_buf(pk_resp_packet.public_key, pk_resp_packet.public_key_len);
ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL);
BIO_free(bio);
}
ret = mysqlnd_sha256_get_rsa_from_pem((const char *) pk_resp_packet.public_key, pk_resp_packet.public_key_len);
} while (0);
PACKET_FREE(&req_packet);
PACKET_FREE(&pk_resp_packet);
@@ -995,9 +1162,7 @@ mysqlnd_caching_sha2_get_key(MYSQLND_CONN_DATA *conn)
if (stream) {
if ((key_str = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0)) != NULL) {
BIO * bio = BIO_new_mem_buf(ZSTR_VAL(key_str), ZSTR_LEN(key_str));
ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL);
BIO_free(bio);
ret = mysqlnd_sha256_get_rsa_from_pem(ZSTR_VAL(key_str), ZSTR_LEN(key_str));
DBG_INF("Successfully loaded");
DBG_INF_FMT("Public key:%*.s", ZSTR_LEN(key_str), ZSTR_VAL(key_str));
zend_string_release(key_str);
@@ -1010,7 +1175,7 @@ mysqlnd_caching_sha2_get_key(MYSQLND_CONN_DATA *conn)
}
/* {{{ mysqlnd_caching_sha2_get_key */
/* {{{ mysqlnd_caching_sha2_get_and_use_key */
static size_t
mysqlnd_caching_sha2_get_and_use_key(MYSQLND_CONN_DATA *conn,
const zend_uchar * auth_plugin_data, const size_t auth_plugin_data_len,
@@ -1018,33 +1183,19 @@ mysqlnd_caching_sha2_get_and_use_key(MYSQLND_CONN_DATA *conn,
const char * const passwd,
const size_t passwd_len)
{
static RSA *server_public_key;
server_public_key = mysqlnd_caching_sha2_get_key(conn);
mysqlnd_rsa_t server_public_key = mysqlnd_caching_sha2_get_key(conn);
DBG_ENTER("mysqlnd_caching_sha2_get_and_use_key(");
if (server_public_key) {
int server_public_key_len;
char xor_str[passwd_len + 1];
ALLOCA_FLAG(use_heap)
char *xor_str = do_alloca(passwd_len + 1, use_heap);
memcpy(xor_str, passwd, passwd_len);
xor_str[passwd_len] = '\0';
mysqlnd_xor_string(xor_str, passwd_len, (char *) auth_plugin_data, SCRAMBLE_LENGTH);
server_public_key_len = RSA_size(server_public_key);
/*
Because RSA_PKCS1_OAEP_PADDING is used there is a restriction on the passwd_len.
RSA_PKCS1_OAEP_PADDING is recommended for new applications. See more here:
http://www.openssl.org/docs/crypto/RSA_public_encrypt.html
*/
if ((size_t) server_public_key_len - 41 <= passwd_len) {
/* password message is to long */
SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
DBG_ERR("password is too long");
DBG_RETURN(0);
}
*crypted = emalloc(server_public_key_len);
RSA_public_encrypt(passwd_len + 1, (zend_uchar *) xor_str, *crypted, server_public_key, RSA_PKCS1_OAEP_PADDING);
server_public_key_len = mysqlnd_caching_sha2_public_encrypt(conn, server_public_key, passwd_len, crypted, xor_str);
free_alloca(xor_str, use_heap);
DBG_RETURN(server_public_key_len);
}
DBG_RETURN(0);
-7
View File
@@ -2141,12 +2141,8 @@ size_t php_mysqlnd_cached_sha2_result_write(MYSQLND_CONN_DATA * conn, void * _pa
MYSQLND_PFC * pfc = conn->protocol_frame_codec;
MYSQLND_VIO * vio = conn->vio;
MYSQLND_STATS * stats = conn->stats;
#if HAVE_COMPILER_C99_VLA
zend_uchar buffer[MYSQLND_HEADER_SIZE + packet->password_len + 1];
#else
ALLOCA_FLAG(use_heap)
zend_uchar *buffer = do_alloca(MYSQLND_HEADER_SIZE + packet->password_len + 1, use_heap);
#endif
size_t sent;
DBG_ENTER("php_mysqlnd_cached_sha2_result_write");
@@ -2159,10 +2155,7 @@ size_t php_mysqlnd_cached_sha2_result_write(MYSQLND_CONN_DATA * conn, void * _pa
sent = pfc->data->m.send(pfc, vio, buffer, packet->password_len, stats, error_info);
}
#if !HAVE_COMPILER_C99_VLA
free_alloca(buffer, use_heap);
#endif
DBG_RETURN(sent);
}
+2 -2
View File
@@ -2761,10 +2761,10 @@ static int zend_update_type_info(const zend_op_array *op_array,
}
if ((t1 & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_LONG) {
if (!ssa_var_info[ssa_ops[i].op1_use].has_range ||
(opline->opcode == ZEND_PRE_DEC &&
(opline->opcode == ZEND_POST_DEC &&
(ssa_var_info[ssa_ops[i].op1_use].range.underflow ||
ssa_var_info[ssa_ops[i].op1_use].range.min == ZEND_LONG_MIN)) ||
(opline->opcode == ZEND_PRE_INC &&
(opline->opcode == ZEND_POST_INC &&
(ssa_var_info[ssa_ops[i].op1_use].range.overflow ||
ssa_var_info[ssa_ops[i].op1_use].range.max == ZEND_LONG_MAX))) {
/* may overflow */
+3
View File
@@ -4233,9 +4233,12 @@ static void preload_load(void)
EG(persistent_classes_count) = EG(class_table)->nNumUsed;
}
if (CG(map_ptr_last) != ZCSG(map_ptr_last)) {
size_t old_map_ptr_last = CG(map_ptr_last);
CG(map_ptr_last) = ZCSG(map_ptr_last);
CG(map_ptr_size) = ZEND_MM_ALIGNED_SIZE_EX(CG(map_ptr_last) + 1, 4096);
CG(map_ptr_base) = perealloc(CG(map_ptr_base), CG(map_ptr_size) * sizeof(void*), 1);
memset((void **) CG(map_ptr_base) + old_map_ptr_last, 0,
(CG(map_ptr_last) - old_map_ptr_last) * sizeof(void *));
}
}
+56 -27
View File
@@ -995,6 +995,20 @@ static inline void populate_match_value(
}
}
static inline void add_named(
zval *subpats, zend_string *name, zval *val, zend_bool unmatched) {
/* If the DUPNAMES option is used, multiple subpatterns might have the same name.
* In this case we want to preserve the one that actually has a value. */
if (!unmatched) {
zend_hash_update(Z_ARRVAL_P(subpats), name, val);
} else {
if (!zend_hash_add(Z_ARRVAL_P(subpats), name, val)) {
return;
}
}
Z_TRY_ADDREF_P(val);
}
/* {{{ add_offset_pair */
static inline void add_offset_pair(
zval *result, const char *subject, PCRE2_SIZE start_offset, PCRE2_SIZE end_offset,
@@ -1023,8 +1037,7 @@ static inline void add_offset_pair(
}
if (name) {
Z_ADDREF(match_pair);
zend_hash_update(Z_ARRVAL_P(result), name, &match_pair);
add_named(result, name, &match_pair, start_offset == PCRE2_UNSET);
}
zend_hash_next_index_insert(Z_ARRVAL_P(result), &match_pair);
}
@@ -1054,8 +1067,7 @@ static void populate_subpat_array(
populate_match_value(
&val, subject, offsets[2*i], offsets[2*i+1], unmatched_as_null);
if (subpat_names[i]) {
Z_TRY_ADDREF(val);
zend_hash_update(Z_ARRVAL_P(subpats), subpat_names[i], &val);
add_named(subpats, subpat_names[i], &val, offsets[2*i] == PCRE2_UNSET);
}
zend_hash_next_index_insert(Z_ARRVAL_P(subpats), &val);
}
@@ -1063,7 +1075,7 @@ static void populate_subpat_array(
for (i = count; i < num_subpats; i++) {
ZVAL_NULL(&val);
if (subpat_names[i]) {
zend_hash_update(Z_ARRVAL_P(subpats), subpat_names[i], &val);
zend_hash_add(Z_ARRVAL_P(subpats), subpat_names[i], &val);
}
zend_hash_next_index_insert(Z_ARRVAL_P(subpats), &val);
}
@@ -1130,6 +1142,22 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ *
}
/* }}} */
static zend_always_inline zend_bool is_known_valid_utf8(
zend_string *subject_str, PCRE2_SIZE start_offset) {
if (!(GC_FLAGS(subject_str) & IS_STR_VALID_UTF8)) {
/* We don't know whether the string is valid UTF-8 or not. */
return 0;
}
if (start_offset == ZSTR_LEN(subject_str)) {
/* Degenerate case: Offset points to end of string. */
return 1;
}
/* Check that the offset does not point to an UTF-8 continuation byte. */
return (ZSTR_VAL(subject_str)[start_offset] & 0xc0) != 0x80;
}
/* {{{ php_pcre_match_impl() */
PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, zval *return_value,
zval *subpats, int global, int use_flags, zend_long flags, zend_off_t start_offset)
@@ -1151,7 +1179,7 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str,
PCRE2_SPTR mark = NULL; /* Target for MARK name */
zval marks; /* Array of marks for PREG_PATTERN_ORDER */
pcre2_match_data *match_data;
PCRE2_SIZE start_offset2;
PCRE2_SIZE start_offset2, orig_start_offset;
char *subject = ZSTR_VAL(subject_str);
size_t subject_len = ZSTR_LEN(subject_str);
@@ -1247,8 +1275,10 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str,
}
}
options = (pce->compile_options & PCRE2_UTF) && !(GC_FLAGS(subject_str) & IS_STR_VALID_UTF8)
? 0 : PCRE2_NO_UTF_CHECK;
orig_start_offset = start_offset2;
options =
(pce->compile_options & PCRE2_UTF) && !is_known_valid_utf8(subject_str, orig_start_offset)
? 0 : PCRE2_NO_UTF_CHECK;
/* Execute the regular expression. */
#ifdef HAVE_PCRE_JIT_SUPPORT
@@ -1438,7 +1468,8 @@ error:
if (PCRE_G(error_code) == PHP_PCRE_NO_ERROR) {
/* If there was no error and we're in /u mode, remember that the string is valid UTF-8. */
if ((pce->compile_options & PCRE2_UTF) && !ZSTR_IS_INTERNED(subject_str)) {
if ((pce->compile_options & PCRE2_UTF)
&& !ZSTR_IS_INTERNED(subject_str) && orig_start_offset == 0) {
GC_ADD_FLAGS(subject_str, IS_STR_VALID_UTF8);
}
@@ -1582,6 +1613,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
size_t match_len; /* Length of the current match */
int backref; /* Backreference number */
PCRE2_SIZE start_offset; /* Where the new search starts */
size_t last_end_offset; /* Where the last search ended */
char *walkbuf, /* Location of current replacement in the result */
*walk, /* Used to walk the replacement string */
*match, /* The current match */
@@ -1600,6 +1632,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
/* Initialize */
match = NULL;
start_offset = 0;
last_end_offset = 0;
result_len = 0;
PCRE_G(error_code) = PHP_PCRE_NO_ERROR;
@@ -1626,7 +1659,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
options, match_data, mctx);
while (1) {
piece = subject + start_offset;
piece = subject + last_end_offset;
if (count >= 0 && limit > 0) {
zend_bool simple_string;
@@ -1656,7 +1689,7 @@ matched:
/* Set the match location in subject */
match = subject + offsets[0];
new_len = result_len + offsets[0] - start_offset; /* part before the match */
new_len = result_len + offsets[0] - last_end_offset; /* part before the match */
walk = ZSTR_VAL(replace_str);
replace_end = walk + ZSTR_LEN(replace_str);
@@ -1733,7 +1766,7 @@ matched:
limit--;
/* Advance to the next piece. */
start_offset = offsets[1];
start_offset = last_end_offset = offsets[1];
/* If we have matched an empty string, mimic what Perl's /g options does.
This turns out to be rather cunning. First we set PCRE2_NOTEMPTY_ATSTART and try
@@ -1753,10 +1786,7 @@ matched:
to achieve this, unless we're already at the end of the string. */
if (start_offset < subject_len) {
size_t unit_len = calculate_unit_length(pce, piece);
start_offset += unit_len;
memcpy(ZSTR_VAL(result) + result_len, piece, unit_len);
result_len += unit_len;
} else {
goto not_matched;
}
@@ -1771,7 +1801,7 @@ not_matched:
result = zend_string_copy(subject_str);
break;
}
new_len = result_len + subject_len - start_offset;
new_len = result_len + subject_len - last_end_offset;
if (new_len >= alloc_len) {
alloc_len = new_len; /* now we know exactly how long it is */
if (NULL != result) {
@@ -1781,8 +1811,8 @@ not_matched:
}
}
/* stick that last bit of string on our output */
memcpy(ZSTR_VAL(result) + result_len, piece, subject_len - start_offset);
result_len += subject_len - start_offset;
memcpy(ZSTR_VAL(result) + result_len, piece, subject_len - last_end_offset);
result_len += subject_len - last_end_offset;
ZSTR_VAL(result)[result_len] = '\0';
ZSTR_LEN(result) = result_len;
break;
@@ -1824,6 +1854,7 @@ static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_strin
size_t new_len; /* Length of needed storage */
size_t alloc_len; /* Actual allocated length */
PCRE2_SIZE start_offset; /* Where the new search starts */
size_t last_end_offset; /* Where the last search ended */
char *match, /* The current match */
*piece; /* The current piece of subject */
size_t result_len; /* Length of result */
@@ -1853,6 +1884,7 @@ static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_strin
/* Initialize */
match = NULL;
start_offset = 0;
last_end_offset = 0;
result_len = 0;
PCRE_G(error_code) = PHP_PCRE_NO_ERROR;
@@ -1885,7 +1917,7 @@ static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_strin
options, match_data, mctx);
while (1) {
piece = subject + start_offset;
piece = subject + last_end_offset;
if (count >= 0 && limit) {
/* Check for too many substrings condition. */
@@ -1913,7 +1945,7 @@ matched:
/* Set the match location in subject */
match = subject + offsets[0];
new_len = result_len + offsets[0] - start_offset; /* part before the match */
new_len = result_len + offsets[0] - last_end_offset; /* part before the match */
/* Use custom function to get replacement string and its length. */
eval_result = preg_do_repl_func(
@@ -1945,7 +1977,7 @@ matched:
limit--;
/* Advance to the next piece. */
start_offset = offsets[1];
start_offset = last_end_offset = offsets[1];
/* If we have matched an empty string, mimic what Perl's /g options does.
This turns out to be rather cunning. First we set PCRE2_NOTEMPTY_ATSTART and try
@@ -1965,10 +1997,7 @@ matched:
to achieve this, unless we're already at the end of the string. */
if (start_offset < subject_len) {
size_t unit_len = calculate_unit_length(pce, piece);
start_offset += unit_len;
memcpy(ZSTR_VAL(result) + result_len, piece, unit_len);
result_len += unit_len;
} else {
goto not_matched;
}
@@ -1983,7 +2012,7 @@ not_matched:
result = zend_string_copy(subject_str);
break;
}
new_len = result_len + subject_len - start_offset;
new_len = result_len + subject_len - last_end_offset;
if (new_len >= alloc_len) {
alloc_len = new_len; /* now we know exactly how long it is */
if (NULL != result) {
@@ -1993,8 +2022,8 @@ not_matched:
}
}
/* stick that last bit of string on our output */
memcpy(ZSTR_VAL(result) + result_len, piece, subject_len - start_offset);
result_len += subject_len - start_offset;
memcpy(ZSTR_VAL(result) + result_len, piece, subject_len - last_end_offset);
result_len += subject_len - last_end_offset;
ZSTR_VAL(result)[result_len] = '\0';
ZSTR_LEN(result) = result_len;
break;
+13
View File
@@ -0,0 +1,13 @@
--TEST--
Bug #79188: Memory corruption in preg_replace/preg_replace_callback and unicode
--FILE--
<?php
var_dump(preg_replace("//u", "", "a" . str_repeat("\u{1f612}", 10)));
var_dump(preg_replace_callback(
"//u", function() { return ""; }, "a" . str_repeat("\u{1f612}", 10)));
?>
--EXPECT--
string(41) "a😒😒😒😒😒😒😒😒😒😒"
string(41) "a😒😒😒😒😒😒😒😒😒😒"
+35
View File
@@ -0,0 +1,35 @@
--TEST--
Bug #79241: Segmentation fault on preg_match()
--SKIPIF--
<?php if (!extension_loaded("json")) print "skip json extension missing"; ?>
--FILE--
<?php
// if "’" string is used directly without json_decode,
// the issue does not reproduce
$text = json_decode('"’"');
$pattern = '/\b/u';
// it has to be exact two calls to preg_match(),
// with the second call offsetting after the tick symbol
var_dump(preg_match($pattern, $text, $matches, 0, 0));
var_dump(preg_match($pattern, $text, $matches, 0, 1));
var_dump(preg_last_error() == PREG_BAD_UTF8_OFFSET_ERROR);
echo "\n";
$text = "VA\xff"; $text .= "LID";
var_dump(preg_match($pattern, $text, $matches, 0, 4));
var_dump(preg_match($pattern, $text, $matches, 0, 0));
var_dump(preg_last_error() == PREG_BAD_UTF8_ERROR);
?>
--EXPECT--
int(0)
bool(false)
bool(true)
int(1)
bool(false)
bool(true)
+218
View File
@@ -0,0 +1,218 @@
--TEST--
Bug #79257: Duplicate named groups (?J) prefer last alternative even if not matched
--FILE--
<?php
preg_match('/(?J)(?:(?<g>foo)|(?<g>bar))/', 'foo', $matches);
var_dump($matches);
preg_match('/(?J)(?:(?<g>foo)|(?<g>bar))/', 'foo', $matches,
PREG_UNMATCHED_AS_NULL);
var_dump($matches);
preg_match('/(?J)(?:(?<g>foo)|(?<g>bar))/', 'foo', $matches,
PREG_OFFSET_CAPTURE);
var_dump($matches);
preg_match('/(?J)(?:(?<g>foo)|(?<g>bar))/', 'foo', $matches,
PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE);
var_dump($matches);
preg_match('/(?J)(?:(?<g>foo)|(?<g>bar))(?<h>baz)/', 'foobaz', $matches);
var_dump($matches);
preg_match('/(?J)(?:(?<g>foo)|(?<g>bar))(?<h>baz)/', 'foobaz', $matches,
PREG_UNMATCHED_AS_NULL);
var_dump($matches);
preg_match('/(?J)(?:(?<g>foo)|(?<g>bar))(?<h>baz)/', 'foobaz', $matches,
PREG_OFFSET_CAPTURE);
var_dump($matches);
preg_match('/(?J)(?:(?<g>foo)|(?<g>bar))(?<h>baz)/', 'foobaz', $matches,
PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE);
var_dump($matches);
?>
--EXPECT--
array(3) {
[0]=>
string(3) "foo"
["g"]=>
string(3) "foo"
[1]=>
string(3) "foo"
}
array(4) {
[0]=>
string(3) "foo"
["g"]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
NULL
}
array(3) {
[0]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
int(0)
}
["g"]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
int(0)
}
[1]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
int(0)
}
}
array(4) {
[0]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
int(0)
}
["g"]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
int(0)
}
[1]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
int(0)
}
[2]=>
array(2) {
[0]=>
NULL
[1]=>
int(-1)
}
}
array(6) {
[0]=>
string(6) "foobaz"
["g"]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
string(0) ""
["h"]=>
string(3) "baz"
[3]=>
string(3) "baz"
}
array(6) {
[0]=>
string(6) "foobaz"
["g"]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
NULL
["h"]=>
string(3) "baz"
[3]=>
string(3) "baz"
}
array(6) {
[0]=>
array(2) {
[0]=>
string(6) "foobaz"
[1]=>
int(0)
}
["g"]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
int(0)
}
[1]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
int(0)
}
[2]=>
array(2) {
[0]=>
string(0) ""
[1]=>
int(-1)
}
["h"]=>
array(2) {
[0]=>
string(3) "baz"
[1]=>
int(3)
}
[3]=>
array(2) {
[0]=>
string(3) "baz"
[1]=>
int(3)
}
}
array(6) {
[0]=>
array(2) {
[0]=>
string(6) "foobaz"
[1]=>
int(0)
}
["g"]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
int(0)
}
[1]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
int(0)
}
[2]=>
array(2) {
[0]=>
NULL
[1]=>
int(-1)
}
["h"]=>
array(2) {
[0]=>
string(3) "baz"
[1]=>
int(3)
}
[3]=>
array(2) {
[0]=>
string(3) "baz"
[1]=>
int(3)
}
}
+19 -5
View File
@@ -126,13 +126,14 @@ static void free_cols(pdo_stmt_t *stmt, pdo_odbc_stmt *S)
if (S->cols) {
int i;
for (i = 0; i < stmt->column_count; i++) {
for (i = 0; i < S->col_count; i++) {
if (S->cols[i].data) {
efree(S->cols[i].data);
}
}
efree(S->cols);
S->cols = NULL;
S->col_count = 0;
}
}
@@ -262,14 +263,14 @@ static int odbc_stmt_execute(pdo_stmt_t *stmt)
SQLRowCount(S->stmt, &row_count);
stmt->row_count = row_count;
if (!stmt->executed) {
if (S->cols == NULL) {
/* do first-time-only definition of bind/mapping stuff */
SQLSMALLINT colcount;
/* how many columns do we have ? */
SQLNumResultCols(S->stmt, &colcount);
stmt->column_count = (int)colcount;
stmt->column_count = S->col_count = (int)colcount;
S->cols = ecalloc(colcount, sizeof(pdo_odbc_column));
S->going_long = 0;
}
@@ -847,13 +848,25 @@ static int odbc_stmt_next_rowset(pdo_stmt_t *stmt)
free_cols(stmt, S);
/* how many columns do we have ? */
SQLNumResultCols(S->stmt, &colcount);
stmt->column_count = (int)colcount;
stmt->column_count = S->col_count = (int)colcount;
S->cols = ecalloc(colcount, sizeof(pdo_odbc_column));
S->going_long = 0;
return 1;
}
static int odbc_stmt_close_cursor(pdo_stmt_t *stmt)
{
SQLRETURN rc;
pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data;
rc = SQLCloseCursor(S->stmt);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
return 0;
}
return 1;
}
const struct pdo_stmt_methods odbc_stmt_methods = {
odbc_stmt_dtor,
odbc_stmt_execute,
@@ -864,5 +877,6 @@ const struct pdo_stmt_methods odbc_stmt_methods = {
odbc_stmt_set_param,
odbc_stmt_get_attr, /* get attr */
NULL, /* get column meta */
odbc_stmt_next_rowset
odbc_stmt_next_rowset,
odbc_stmt_close_cursor
};
+2 -1
View File
@@ -151,7 +151,8 @@ typedef struct {
zend_ulong convbufsize;
unsigned going_long:1;
unsigned assume_utf8:1;
unsigned _spare:30;
signed col_count:16;
unsigned _spare:14;
} pdo_odbc_stmt;
typedef struct {
+12 -1
View File
@@ -1419,6 +1419,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */
char *str_key;
zend_class_entry *ce = p_obj->c;
phar_archive_object *phar_obj = p_obj->p;
php_stream_statbuf ssb;
value = iter->funcs->get_current_data(iter);
@@ -1686,6 +1687,16 @@ after_open_fp:
php_stream_copy_to_stream_ex(fp, p_obj->fp, PHP_STREAM_COPY_ALL, &contents_len);
data->internal_file->uncompressed_filesize = data->internal_file->compressed_filesize =
php_stream_tell(p_obj->fp) - data->internal_file->offset;
if (php_stream_stat(fp, &ssb) != -1) {
data->internal_file->flags = ssb.sb.st_mode & PHAR_ENT_PERM_MASK ;
} else {
#ifndef _WIN32
mode_t mask;
mask = umask(0);
umask(mask);
data->internal_file->flags &= ~mask;
#endif
}
}
if (close_fp) {
@@ -4173,7 +4184,7 @@ static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char *
if ('\\' == filename[cnt]) {
filename[cnt] = '/';
}
} while (cnt++ <= filename_len);
} while (cnt++ < filename_len);
}
#endif
+52
View File
@@ -0,0 +1,52 @@
--TEST--
Phar: Bug #79082: Files added to tar with Phar::buildFromIterator have all-access permissions
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
if (defined("PHP_WINDOWS_VERSION_MAJOR")) die("skip not for Windows")
?>
--FILE--
<?php
umask(022);
var_dump(decoct(umask()));
chmod(__DIR__ . '/test79082/test79082-testfile', 0644);
chmod(__DIR__ . '/test79082/test79082-testfile2', 0400);
foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $mode => $ext) {
clearstatcache();
$phar = new PharData(__DIR__ . '/test79082.' . $ext, null, null, $mode);
$phar->buildFromIterator(new \RecursiveDirectoryIterator(__DIR__ . '/test79082', \FilesystemIterator::SKIP_DOTS), __DIR__ . '/test79082');
$phar->extractTo(__DIR__);
var_dump(decoct(stat(__DIR__ . '/test79082-testfile')['mode']));
var_dump(decoct(stat(__DIR__ . '/test79082-testfile2')['mode']));
unlink(__DIR__ . '/test79082-testfile');
unlink(__DIR__ . '/test79082-testfile2');
}
foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $mode => $ext) {
clearstatcache();
$phar = new PharData(__DIR__ . '/test79082-d.' . $ext, null, null, $mode);
$phar->buildFromDirectory(__DIR__ . '/test79082');
$phar->extractTo(__DIR__);
var_dump(decoct(stat(__DIR__ . '/test79082-testfile')['mode']));
var_dump(decoct(stat(__DIR__ . '/test79082-testfile2')['mode']));
unlink(__DIR__ . '/test79082-testfile');
unlink(__DIR__ . '/test79082-testfile2');
}
?>
--CLEAN--
<?
unlink(__DIR__ . '/test79082.tar');
unlink(__DIR__ . '/test79082.zip');
unlink(__DIR__ . '/test79082-d.tar');
unlink(__DIR__ . '/test79082-d.zip');
?>
--EXPECT--
string(2) "22"
string(6) "100644"
string(6) "100400"
string(6) "100644"
string(6) "100400"
string(6) "100644"
string(6) "100400"
string(6) "100644"
string(6) "100400"
@@ -0,0 +1 @@
test
@@ -0,0 +1 @@
test
+34
View File
@@ -0,0 +1,34 @@
--TEST--
Bug #79062: Property with heredoc default value returns false for getDocComment
--FILE--
<?php
class BugReportMailrcConfigTests
{
/** @var string */
private $s1 = <<<STRING
I'm a string :(
STRING;
/** @var string */
private $s2 = <<<'STRING'
I'm a string :)
STRING;
/** @var string */
private $s3 = 'I\'m a string :)';
}
$ref = new \ReflectionClass(BugReportMailrcConfigTests::class);
$s1 = $ref->getProperty('s1');
var_dump($s1->getDocComment());
$s2 = $ref->getProperty('s2');
var_dump($s2->getDocComment());
$s3 = $ref->getProperty('s3');
var_dump($s2->getDocComment());
?>
--EXPECT--
string(18) "/** @var string */"
string(18) "/** @var string */"
string(18) "/** @var string */"
+6 -4
View File
@@ -3320,10 +3320,12 @@ static int php_session_rfc1867_callback(unsigned int event, void *event_data, vo
if (PS(rfc1867_cleanup)) {
php_session_rfc1867_cleanup(progress);
} else {
SEPARATE_ARRAY(&progress->data);
add_assoc_bool_ex(&progress->data, "done", sizeof("done") - 1, 1);
Z_LVAL_P(progress->post_bytes_processed) = data->post_bytes_processed;
php_session_rfc1867_update(progress, 1);
if (!Z_ISUNDEF(progress->data)) {
SEPARATE_ARRAY(&progress->data);
add_assoc_bool_ex(&progress->data, "done", sizeof("done") - 1, 1);
Z_LVAL_P(progress->post_bytes_processed) = data->post_bytes_processed;
php_session_rfc1867_update(progress, 1);
}
}
php_rshutdown_session_globals();
}
+45
View File
@@ -0,0 +1,45 @@
--TEST--
Null Pointer Dereference in PHP Session Upload Progress
--INI--
error_reporting=0
file_uploads=1
upload_max_filesize=1024
session.save_path=
session.name=PHPSESSID
session.serialize_handler=php
session.use_strict_mode=0
session.use_cookies=1
session.use_only_cookies=0
session.upload_progress.enabled=1
session.upload_progress.cleanup=0
session.upload_progress.prefix=upload_progress_
session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.freq=1%
session.upload_progress.min_freq=0.000000001
--COOKIE--
PHPSESSID=session-upload
--POST_RAW--
Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737
-----------------------------20896060251896012921717172737
Content-Disposition: form-data; name="PHPSESSID"
session-upload
-----------------------------20896060251896012921717172737
Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS"
ryat
-----------------------------20896060251896012921717172737
Content-Disposition: form-data; file="file"; ryat="filename"
1
-----------------------------20896060251896012921717172737--
--FILE--
<?php
session_start();
var_dump($_SESSION);
session_destroy();
--EXPECTF--
array(0) {
}
+1
View File
@@ -3,6 +3,7 @@ Bug #78516 (password_hash(): Memory cost is not in allowed range)
--SKIPIF--
<?php
if (!extension_loaded('sodium')) die('skip sodium extension not available');
if (!defined('PASSWORD_ARGON2ID')) die('skip PASSWORD_ARGON2ID not available');
?>
--FILE--
<?php
+1 -1
View File
@@ -108,7 +108,7 @@ struct _php_sqlite3_result_object {
zval stmt_obj_zval;
int is_prepared_statement;
int complete;
int complete; // unused
zend_object zo;
};
+1 -4
View File
@@ -1983,7 +1983,7 @@ PHP_METHOD(sqlite3result, columnType)
return;
}
if (result_obj->complete) {
if (!sqlite3_data_count(result_obj->stmt_obj->stmt)) {
RETURN_FALSE;
}
@@ -2038,7 +2038,6 @@ PHP_METHOD(sqlite3result, fetchArray)
break;
case SQLITE_DONE:
result_obj->complete = 1;
RETURN_FALSE;
break;
@@ -2066,8 +2065,6 @@ PHP_METHOD(sqlite3result, reset)
RETURN_FALSE;
}
result_obj->complete = 0;
RETURN_TRUE;
}
/* }}} */
+34
View File
@@ -0,0 +1,34 @@
--TEST--
Bug #79294 ()::columnType() may fail after SQLite3Stmt::reset())
--SKIPIF--
<?php
if (!extension_loaded('sqlite3')) die('sqlite3 extension not available');
?>
--FILE--
<?php
$db = new SQLite3(':memory:');
$db->exec("CREATE TABLE foo (bar INT)");
$db->exec("INSERT INTO foo VALUES (1)");
$stmt = $db->prepare("SELECT * FROM foo");
$res = $stmt->execute();
var_dump($res->fetchArray() !== false);
var_dump($res->columnType(0));
var_dump($res->fetchArray() !== false);
var_dump($res->columnType(0));
$stmt->reset();
var_dump($res->fetchArray() !== false);
var_dump($res->columnType(0));
$res->reset();
var_dump($res->fetchArray() !== false);
var_dump($res->columnType(0));
?>
--EXPECT--
bool(true)
int(1)
bool(false)
bool(false)
bool(true)
int(1)
bool(true)
int(1)
+28 -31
View File
@@ -105,6 +105,17 @@ static inline void strip_header(char *header_bag, char *lc_header_bag,
}
}
static zend_bool check_has_header(const char *headers, const char *header) {
const char *s = headers;
while ((s = strstr(s, header))) {
if (s == headers || *(s-1) == '\n') {
return 1;
}
s++;
}
return 0;
}
static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
const char *path, const char *mode, int options, zend_string **opened_path,
php_stream_context *context, int redirect_max, int flags,
@@ -459,45 +470,31 @@ finish:
strip_header(user_headers, t, "content-type:");
}
if ((s = strstr(t, "user-agent:")) &&
(s == t || *(s-1) == '\r' || *(s-1) == '\n' ||
*(s-1) == '\t' || *(s-1) == ' ')) {
have_header |= HTTP_HEADER_USER_AGENT;
if (check_has_header(t, "user-agent:")) {
have_header |= HTTP_HEADER_USER_AGENT;
}
if ((s = strstr(t, "host:")) &&
(s == t || *(s-1) == '\r' || *(s-1) == '\n' ||
*(s-1) == '\t' || *(s-1) == ' ')) {
have_header |= HTTP_HEADER_HOST;
if (check_has_header(t, "host:")) {
have_header |= HTTP_HEADER_HOST;
}
if ((s = strstr(t, "from:")) &&
(s == t || *(s-1) == '\r' || *(s-1) == '\n' ||
*(s-1) == '\t' || *(s-1) == ' ')) {
have_header |= HTTP_HEADER_FROM;
}
if ((s = strstr(t, "authorization:")) &&
(s == t || *(s-1) == '\r' || *(s-1) == '\n' ||
*(s-1) == '\t' || *(s-1) == ' ')) {
have_header |= HTTP_HEADER_AUTH;
if (check_has_header(t, "from:")) {
have_header |= HTTP_HEADER_FROM;
}
if ((s = strstr(t, "content-length:")) &&
(s == t || *(s-1) == '\r' || *(s-1) == '\n' ||
*(s-1) == '\t' || *(s-1) == ' ')) {
have_header |= HTTP_HEADER_CONTENT_LENGTH;
if (check_has_header(t, "authorization:")) {
have_header |= HTTP_HEADER_AUTH;
}
if ((s = strstr(t, "content-type:")) &&
(s == t || *(s-1) == '\r' || *(s-1) == '\n' ||
*(s-1) == '\t' || *(s-1) == ' ')) {
have_header |= HTTP_HEADER_TYPE;
if (check_has_header(t, "content-length:")) {
have_header |= HTTP_HEADER_CONTENT_LENGTH;
}
if ((s = strstr(t, "connection:")) &&
(s == t || *(s-1) == '\r' || *(s-1) == '\n' ||
*(s-1) == '\t' || *(s-1) == ' ')) {
have_header |= HTTP_HEADER_CONNECTION;
if (check_has_header(t, "content-type:")) {
have_header |= HTTP_HEADER_TYPE;
}
if (check_has_header(t, "connection:")) {
have_header |= HTTP_HEADER_CONNECTION;
}
/* remove Proxy-Authorization header */
if (use_proxy && use_ssl && (s = strstr(t, "proxy-authorization:")) &&
(s == t || *(s-1) == '\r' || *(s-1) == '\n' ||
*(s-1) == '\t' || *(s-1) == ' ')) {
(s == t || *(s-1) == '\n')) {
char *p = s + sizeof("proxy-authorization:") - 1;
while (s > t && (*(s-1) == ' ' || *(s-1) == '\t')) s--;
+11 -1
View File
@@ -504,6 +504,7 @@ PHP_FUNCTION(proc_open)
int bypass_shell = 0;
int blocking_pipes = 0;
int create_process_group = 0;
int create_new_console = 0;
#else
char **argv = NULL;
#endif
@@ -598,6 +599,13 @@ PHP_FUNCTION(proc_open)
create_process_group = 1;
}
}
item = zend_hash_str_find(Z_ARRVAL_P(other_options), "create_new_console", sizeof("create_new_console") - 1);
if (item != NULL) {
if (Z_TYPE_P(item) == IS_TRUE || ((Z_TYPE_P(item) == IS_LONG) && Z_LVAL_P(item))) {
create_new_console = 1;
}
}
}
#endif
@@ -921,7 +929,9 @@ PHP_FUNCTION(proc_open)
if (create_process_group) {
dwCreateFlags |= CREATE_NEW_PROCESS_GROUP;
}
if (create_new_console) {
dwCreateFlags |= CREATE_NEW_CONSOLE;
}
envpw = php_win32_cp_env_any_to_w(env.envp);
if (envpw) {
dwCreateFlags |= CREATE_UNICODE_ENVIRONMENT;
@@ -1,3 +0,0 @@
# These tests depend on the console codepage, which is shared across all parallel workers.
# Force these tests to run sequentially to make sure the codepage isn't change by another process.
all
@@ -0,0 +1,20 @@
--TEST--
Bug #78569 (proc_open() may require extra quoting)
--SKIPIF--
<?php
if (PHP_OS_FAMILY !== 'Windows') die('skip this test is for Windows platforms only');
?>
--XFAIL--
Before PHP 8.0.0 we would need to add extra quotes.
--FILE--
<?php
// We are searching for the following line:
// FIND ME
$descriptorspec = array(['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']);
$cmd = sprintf('"findstr" "/b" "/c:// FIND ME" "%s" 2>&1', __FILE__);
$proc = proc_open($cmd, $descriptorspec, $pipes);
fpassthru($pipes[1]);
proc_close($proc);
?>
--EXPECT--
// FIND ME
@@ -0,0 +1,22 @@
--TEST--
Bug #79254 (getenv() w/o arguments not showing changes)
--FILE--
<?php
$old = getenv();
var_dump(getenv("PHP_BUG_79254", true));
putenv("PHP_BUG_79254=BAR");
$new = getenv();
var_dump(array_diff($new, $old));
var_dump(getenv("PHP_BUG_79254", true));
?>
--EXPECT--
bool(false)
array(1) {
["PHP_BUG_79254"]=>
string(3) "BAR"
}
string(3) "BAR"
+39
View File
@@ -0,0 +1,39 @@
--TEST--
Bug #79265 (Improper injection of Host header when using fopen for http requests)
--INI--
allow_url_fopen=1
--SKIPIF--
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
--FILE--
<?php
require 'server.inc';
$responses = array(
"data://text/plain,HTTP/1.0 200 OK\r\n\r\n",
);
$pid = http_server("tcp://127.0.0.1:12342", $responses, $output);
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"RandomHeader: localhost:8080\r\n" .
"Cookie: foo=bar\r\n" .
"Host: userspecifiedvalue\r\n"
)
);
$context = stream_context_create($opts);
$fd = fopen('http://127.0.0.1:12342/', 'rb', false, $context);
fseek($output, 0, SEEK_SET);
echo stream_get_contents($output);
fclose($fd);
http_server_kill($pid);
?>
--EXPECT--
GET / HTTP/1.0
Connection: close
RandomHeader: localhost:8080
Cookie: foo=bar
Host: userspecifiedvalue
+38
View File
@@ -0,0 +1,38 @@
--TEST--
Bug #79265 variation: "host:" not at start of header
--INI--
allow_url_fopen=1
--SKIPIF--
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
--FILE--
<?php
require 'server.inc';
$responses = array(
"data://text/plain,HTTP/1.0 200 OK\r\n\r\n",
);
$pid = http_server("tcp://127.0.0.1:12342", $responses, $output);
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"RandomHeader: host:8080\r\n" .
"Cookie: foo=bar\r\n"
)
);
$context = stream_context_create($opts);
$fd = fopen('http://127.0.0.1:12342/', 'rb', false, $context);
fseek($output, 0, SEEK_SET);
echo stream_get_contents($output);
fclose($fd);
http_server_kill($pid);
?>
--EXPECT--
GET / HTTP/1.0
Host: 127.0.0.1:12342
Connection: close
RandomHeader: host:8080
Cookie: foo=bar
+1 -1
View File
@@ -667,7 +667,7 @@ PHP_FUNCTION(get_headers)
php_stream_context *context;
ZEND_PARSE_PARAMETERS_START(1, 3)
Z_PARAM_STRING(url, url_len)
Z_PARAM_PATH(url, url_len)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(format)
Z_PARAM_RESOURCE_EX(zcontext, 1, 0)
+2 -1
View File
@@ -1791,7 +1791,8 @@ static ZIPARCHIVE_METHOD(addFile)
entry_name_len = ZSTR_LEN(filename);
}
if (php_zip_add_file(intern, ZSTR_VAL(filename), ZSTR_LEN(filename), entry_name, entry_name_len, 0, 0) < 0) {
if (php_zip_add_file(intern, ZSTR_VAL(filename), ZSTR_LEN(filename),
entry_name, entry_name_len, offset_start, offset_len) < 0) {
RETURN_FALSE;
} else {
RETURN_TRUE;
+13 -2
View File
@@ -20,23 +20,34 @@ if (!$zip->open($file)) {
if (!$zip->addFile($dirname . 'utils.inc', 'test.php')) {
echo "failed\n";
}
if (!$zip->addFile($dirname . 'utils.inc', 'mini.txt', 12, 34)) {
echo "failed\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
if (!verify_entries($zip, [
"bar",
"foobar/",
"foobar/baz",
"entry1.txt",
"test.php"
"test.php",
"mini.txt"
])) {
echo "failed\n";
} else {
echo "OK";
echo "OK\n";
}
$zip->close();
} else {
echo "failed\n";
}
if (!$zip->open($file)) {
exit('failed');
}
var_dump(strlen($zip->getFromName('test.php')) == filesize($dirname . 'utils.inc'));
var_dump(strlen($zip->getFromName('mini.txt')) == 34);
@unlink($file);
?>
--EXPECT--
OK
bool(true)
bool(true)
+43 -24
View File
@@ -540,39 +540,58 @@ static zend_always_inline int valid_environment_name(const char *name, const cha
return 1;
}
void _php_import_environment_variables(zval *array_ptr)
static zend_always_inline void import_environment_variable(HashTable *ht, char *env)
{
char **env, *p;
char *p;
size_t name_len, len;
zval val;
zend_ulong idx;
p = strchr(env, '=');
if (!p
|| p == env
|| !valid_environment_name(env, p)) {
/* malformed entry? */
return;
}
name_len = p - env;
p++;
len = strlen(p);
if (len == 0) {
ZVAL_EMPTY_STRING(&val);
} else if (len == 1) {
ZVAL_INTERNED_STR(&val, ZSTR_CHAR((zend_uchar)*p));
} else {
ZVAL_NEW_STR(&val, zend_string_init(p, len, 0));
}
if (ZEND_HANDLE_NUMERIC_STR(env, name_len, idx)) {
zend_hash_index_update(ht, idx, &val);
} else {
php_register_variable_quick(env, name_len, &val, ht);
}
}
void _php_import_environment_variables(zval *array_ptr)
{
#ifndef PHP_WIN32
char **env;
#else
char *environment, *env;
#endif
tsrm_env_lock();
#ifndef PHP_WIN32
for (env = environ; env != NULL && *env != NULL; env++) {
p = strchr(*env, '=');
if (!p
|| p == *env
|| !valid_environment_name(*env, p)) {
/* malformed entry? */
continue;
}
name_len = p - *env;
p++;
len = strlen(p);
if (len == 0) {
ZVAL_EMPTY_STRING(&val);
} else if (len == 1) {
ZVAL_INTERNED_STR(&val, ZSTR_CHAR((zend_uchar)*p));
} else {
ZVAL_NEW_STR(&val, zend_string_init(p, len, 0));
}
if (ZEND_HANDLE_NUMERIC_STR(*env, name_len, idx)) {
zend_hash_index_update(Z_ARRVAL_P(array_ptr), idx, &val);
} else {
php_register_variable_quick(*env, name_len, &val, Z_ARRVAL_P(array_ptr));
}
import_environment_variable(Z_ARRVAL_P(array_ptr), *env);
}
#else
environment = GetEnvironmentStringsA();
for (env = environment; env != NULL && *env; env += strlen(env) + 1) {
import_environment_variable(Z_ARRVAL_P(array_ptr), env);
}
FreeEnvironmentStringsA(environment);
#endif
tsrm_env_unlock();
}
+4 -4
View File
@@ -2,7 +2,7 @@
/* edit configure.ac to change version number */
#define PHP_MAJOR_VERSION 7
#define PHP_MINOR_VERSION 4
#define PHP_RELEASE_VERSION 3
#define PHP_EXTRA_VERSION "-dev"
#define PHP_VERSION "7.4.3-dev"
#define PHP_VERSION_ID 70403
#define PHP_RELEASE_VERSION 4
#define PHP_EXTRA_VERSION ""
#define PHP_VERSION "7.4.4"
#define PHP_VERSION_ID 70404
Loaded 100 of 113 files, more files were not shown because too many files have changed in this diff. Show more