1
0
mirror of https://github.com/php/php-src.git synced 2026-04-26 17:38:14 +02:00
Commit Graph

16964 Commits

Author SHA1 Message Date
Dmitry Stogov c7fdf9c139 Avoid class name validation if it's already have IS_STR_CLASS_NAME_MAP_PTR flag. 2021-09-01 16:02:11 +03:00
Nikita Popov 27901e0f6a Restore dev version 2021-09-01 09:56:54 +02:00
Patrick Allaert 5764414eb8 Prepare for PHP 8.1.0RC1 2021-08-31 18:57:44 +02:00
Nikita Popov 14f599ea7d Use zend_long for resource ID
Currently, resource IDs are limited to 32-bits. As resource IDs
are not reused, this means that resource ID overflow for
long-running processes is very possible.

This patch switches resource IDs to use zend_long instead, which
means that on 64-bit systems, 64-bit resource IDs will be used.
This makes resource ID overflow practically impossible.

The tradeoff is an 8 byte increase in zend_resource size.

Closes GH-7436.
2021-08-31 14:58:59 +02:00
Nikita Popov 9b170a41a7 Mark private function as static 2021-08-31 14:54:02 +02:00
Nikita Popov c03f97cd1c Add missing const qualitier in zend_register_internal_enum() 2021-08-31 13:12:31 +02:00
Nikita Popov 5b2ddf5a17 Export zend_use_resource_as_offset()
Use a common implementation to generate this error message, as
we do so in quite a few places dealing with array keys.
2021-08-31 10:58:01 +02:00
Nikita Popov 7d6a7e78fc Use array_set_zval_key() in zend_ast_add_array_element()
This reimplemented basically the same logic.
2021-08-31 10:52:21 +02:00
Nikita Popov 65428d8768 Merge branch 'PHP-8.0'
* PHP-8.0:
  Error on resource ID space overflow
2021-08-31 10:42:59 +02:00
Nikita Popov 1d506250bf Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Error on resource ID space overflow
2021-08-31 10:42:52 +02:00
Nikita Popov 501f1a45f5 Error on resource ID space overflow
When more than INT_MAX resource are created, throw a fatal error,
rather than reusing already allocated IDs, which will result in
assertion failures or crashes down the line.

This doesn't fix the fundamental problem, but makes the failure
more graceful with an obvious cause.

Inspired by https://bugs.php.net/bug.php?id=81399.

Closes GH-7428.
2021-08-31 10:41:57 +02:00
Denis Ryabov d3a6054d44 Fix/improve handling of escaping in ini parser
Quoting from UPGRADING:

- A leading dollar in a quoted string can now be escaped: "\${" will now be
  interpreted as a string with contents `${`.

- Backslashes in double quoted strings are now more consistently treated as
  escape characters. Previously, "foo\\" followed by something other than a
  newline was not considered as a teminated string. It is now interpreted as a
  string with contents `foo\`. However, as an exception, the string "foo\"
  followed by a newline will continue to be treated as a valid string with
  contents `foo\` rather than an unterminated string. This exception exists to
  support naive uses of Windows file pahts as "C:\foo\".

Closes GH-7420.
2021-08-30 16:59:22 +02:00
Máté Kocsis c19e4b9997 Generate optimizer func info from stubs for ext/standard - part 3 (#7426) 2021-08-30 15:56:47 +02:00
Máté Kocsis 1bf1481a2a Specify a few array func info entries (#7425) 2021-08-30 14:29:18 +02:00
Máté Kocsis 8e6e9838b0 Add support for generating MAY_BE_ARRAY_OF_REF func info flag (#7416) 2021-08-30 13:50:34 +02:00
Nikita Popov fab1222128 Ensure stub files are processed in predictable order
The zend_func_infos.h file was generated in a different order for
me.
2021-08-30 10:28:22 +02:00
Nikita Popov 0f7e0cf34b str_replace() can return the original string 2021-08-30 10:23:09 +02:00
Máté Kocsis b49d340f74 Generate optimizer func info from stubs for ext/standard - part 2 (#7414) 2021-08-27 16:54:04 +02:00
Máté Kocsis 3f0b586338 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix a few func info
2021-08-27 16:48:06 +02:00
Nikita Popov 51a504c8be Avoid string copy in get_cfg_var()
basic_functions.c already has a macro for returning an ini
value to userland, so make use of it for get_cfg_var() as well,
after generalizing it to not write to return_value in particular.
2021-08-27 15:34:46 +02:00
Máté Kocsis 1ce81b6bcd Generate optimizer func info from stubs for ext/standard - part 1 (#7413) 2021-08-27 13:11:57 +02:00
Máté Kocsis 8712fb5fe8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix func info for str_replace() and str_ireplace()
2021-08-27 12:56:14 +02:00
Nikita Popov 7157a2a9ee Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove incorrect refcount info for addcslashes()
2021-08-27 12:13:57 +02:00
Nikita Popov 2cc47a04df Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix Closure::call() on internal method closure
2021-08-27 12:00:07 +02:00
Nikita Popov 2467f759f5 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix Closure::call() on internal method closure
2021-08-27 11:59:38 +02:00
Nikita Popov eda9f5f740 Fix Closure::call() on internal method closure
In this case we should use the original internal handler. Otherwise
the trampoline will attempt to free the closure, but the function
being used is not actually part of a closure anymore.
2021-08-27 11:58:13 +02:00
Nikita Popov 4fcf0db649 Fix use after free when rebinding __call closure
We would end up freeing the function name twice here, once for
the original closure, and once for the rebound one.

Rather than further special casing the zend_closure_call_magic
case, always addref the function_name for internal functions,
the same we do for userland functions. To compensate, we need to
release the original function name when creating from callable
or call frame.

Fixes oss-fuzz #37695.
2021-08-27 11:34:22 +02:00
Máté Kocsis fdc6082902 Generate optimizer func info from stubs for various extensions (#7409)
ext/hash, ext/iconv, ext/mbstring, ext/xml, ext/zlib
2021-08-26 19:52:11 +02:00
Máté Kocsis 68946bdd90 Generate optimizer func info from stubs for ext/gd and ext/pgsql (#7408) 2021-08-26 17:38:08 +02:00
Máté Kocsis 17ccabc6b6 Generate optimizer func info from stubs for ext/curl, ext/mysqli, ext/pcre (#7407) 2021-08-26 17:11:45 +02:00
Nikita Popov 6e1bedea5b Merge branch 'PHP-8.0'
* PHP-8.0:
  imagecolorsforindex() cannot return false
2021-08-26 16:37:05 +02:00
Patrick Allaert d630bbdc06 Fixed Dmitry Stogov email
Noticed by Luc Vieillescazes
2021-08-26 16:24:43 +02:00
Máté Kocsis 5e424d2884 Fix a few ext/date return types 2021-08-26 15:26:13 +02:00
Nikita Popov fa032764db Initialize method_lcname to suppress maybe-uninitialized warning 2021-08-26 14:15:39 +02:00
Nikita Popov 6434c93a27 Explicitly store real map ptr base
If we only store the biased pointer, the map ptr region will not
be recognized as reachable memory by leak checkers. This is
primarily problematic for fuzzing, because this is persistent
memory that may be reallocated during the request, without being
an actual leak.

Avoid this by simply storing both the real base pointer of the
allocation, as well as the biased base pointer used for accesses.
2021-08-26 12:29:44 +02:00
Máté Kocsis 9cd6c57ad1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Sync ext/mysqli optimizer func info entries with the stubs
2021-08-26 12:14:21 +02:00
Nikita Popov b964d007e3 Fix AST print of first class callable in anon class expr
This will cause a compile error later, but the expression is
printed first.

Fixes oss-fuzz #37473.
2021-08-26 12:00:37 +02:00
Nikita Popov 07984435ae Mark private compiler functions as static 2021-08-26 11:29:44 +02:00
Máté Kocsis 765aec8623 Generate optimizer func info from stubs for ext/sodium (#7404) 2021-08-26 10:44:38 +02:00
Máté Kocsis 2d248c80b9 Generate optimizer func info from stubs for ext/date (#7403) 2021-08-25 21:29:46 +02:00
Máté Kocsis 50f31829b1 Generate optimizer func info from stubs for a few extensions - part 2 (#7401)
ext/bcmath, ext/fileinfo, ext/filter, ext/gettext, ext/session
2021-08-25 15:29:46 +02:00
Máté Kocsis d379044066 Generate a few missing optimizer function entries from stubs 2021-08-25 10:37:43 +02:00
Máté Kocsis 4a7a414735 Fix callable and iterable handling 2021-08-25 10:37:43 +02:00
Máté Kocsis bdfe0ab505 Generate Zend, ext/spl and ext/json optimizer func info from stubs
Closes GH-7397
2021-08-25 10:37:27 +02:00
Máté Kocsis b1822899fc Add support for generating optimizer function info from stubs (#7367) 2021-08-24 16:35:33 +02:00
Máté Kocsis 58fcded8ec Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix a few optimizer func info
2021-08-24 15:21:27 +02:00
Nikita Popov a40ccd758c Fixed bug #81377
BP_VAR_UNSET should not result in undefined warnings.
2021-08-24 15:05:53 +02:00
Dmitry Stogov 116fa65482 Fixed ZEND_MAP_PTR_KIND_PTR (it is not used) 2021-08-23 14:04:02 +03:00
Nikita Popov 8c67abb67f Drop gz aliases from func info
Func info does not need to include function aliases, we'll look
up based on the primary function name.
2021-08-23 10:41:41 +02:00
Nikita Popov 2ff496e871 Handle resource table reallocation during shutdown
New resources may be created while closing resources during
shutdown. This may result in a reallocation of arData and use
after free.

This problem was exposed by 7f7a90b2bc,
which creates one resources less, and thus moved the reallocation
to shutdown for a number of existing tests. However, the general
problem already existed previously.

We don't try to also close the newly added resources -- we will
later perform a graceful reverse destroy of the table, which will
catch any remaining cases.
2021-08-20 15:37:46 +02:00