Commit Graph

13461 Commits

Author SHA1 Message Date
Sara Golemon
5e1e4a8963
Prep for 8.0.12 2021-09-07 15:16:11 +00:00
Christoph M. Becker
404bed1a69
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81407: shmop_open won't attach and causes php to crash
2021-09-02 23:21:22 +02:00
Christoph M. Becker
58ad403cec
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81407: shmop_open won't attach and causes php to crash
2021-09-02 23:18:53 +02:00
Christoph M. Becker
f3d24af74f
Fix #81407: shmop_open won't attach and causes php to crash
We need to allocate buffers for the file mapping names which are large
enough for all potential keys (`key_t` is defined as `int` on Windows).

Regarding the test: it's probably never a good idea to use hard-coded
keys (should always use `ftok()` instead), but to reliably reproduce
this Windows specific issue we need to, and it shouldn't be an issue on
that OS.

Closes GH-7448.
2021-09-02 23:16:48 +02:00
Dmitry Stogov
cbc925e510 Fixed bug #81409 (Incorrect JIT code for ADD with a reference to array) 2021-09-02 11:13:27 +03:00
Remi Collet
e9228a6a39
NEWS 2021-09-01 15:52:12 +02:00
Remi Collet
fde24e4db0
NEWS + bump zip version 2021-09-01 15:51:24 +02: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
Derick Rethans
2bf451b925 Upgrade timelib to 2021.08, which address some defects and performance
- Fixed bug #80998 (Missing second with inverted interval).
- Speed up finding timezone offset information.
2021-08-31 15:29:48 +01:00
Christoph M. Becker
fcbe737218
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81400: Unterminated string in dns_get_record() results
2021-08-30 18:52:40 +02:00
Christoph M. Becker
edab9ad205
Fix #81400: Unterminated string in dns_get_record() results
If we assemble a zend_string manually, we need to end it with a NUL
byte ourselves.

We also fix the size calculation for that zend_string; there is no need
for the extra byte for each part, and we don't have to multiply by two,
since we're using DnsQuery_A(), not DnsQuery_W () (in which case we
would have to do the character set conversion, anyway).  This avoids
over-allocation, and the need to explicitly set the string length.

Finally, we use the proper access macro for zend_strings.

Closes GH-7427.
2021-08-30 18:49:39 +02:00
Christoph M. Becker
35e1f134f5
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #53580: During resize gdImageCopyResampled cause colors change
2021-08-26 18:41:08 +02:00
Christoph M. Becker
526407ca35
Fix #53580: During resize gdImageCopyResampled cause colors change
We port the upstream fix[1], and also revert commit a3383ac3d7[2] which
is now obsolete, and also not part of libgd.  Especially the change to
gd.png.c was at best a half-baked optimization.

[1] <a24e96f019>
[2] <a3383ac3d7>

Closes GH-7402.
2021-08-26 18:38:17 +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
Christoph M. Becker
521bd7ce15
7.3.31 is next 2021-08-24 12:47:21 +02:00
Stanislav Malyshev
b2008ab97d
Update NEWS 2021-08-23 23:28:27 -07:00
DmitryMaksimov
bdf53cc91f
Dispatch using LANG_NEUTRAL instead of LOCALE_SYSTEM_DEFAULT
This is relevant wrt. case insensitive identifiers.

Closes GH-7391.
2021-08-23 14:07:23 +02:00
Christoph M. Becker
465b3ab2f9
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #78819: Heap Overflow in msg_send
2021-08-18 16:37:58 +02:00
Christoph M. Becker
9494b1cdc4
Fix #78819: Heap Overflow in msg_send
We need to use the proper type.

Closes GH-7386.
2021-08-18 16:35:16 +02:00
Christoph M. Becker
d71a0dcc76
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #73122: Integer Overflow when concatenating strings
2021-08-18 14:52:59 +02:00
Christoph M. Becker
0b7dffb41f
Fix #73122: Integer Overflow when concatenating strings
We must avoid integer overflows in memory allocations, so we introduce
an additional check in the VM, and bail out in the rare case of an
overflow.

Closes GH-7381.
2021-08-18 14:49:09 +02:00
Ben Ramsey
90a6003835
The master branch is now for 8.1.0RC1 2021-08-17 09:40:29 -05:00
Christoph M. Becker
be2df43b08
Fix #78919: CLI server: insufficient cleanup if request startup fails
We need to run the full `php_cli_server_request_shutdown()` in case of
failing `php_cli_server_request_startup()`.

Patch contributed by @cataphract.

Closes GH-7322.
2021-08-17 12:41:06 +02:00
Christoph M. Becker
e45a063f4b
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #71542: disk_total_space does not work with relative paths
2021-08-17 11:31:14 +02:00
Christoph M. Becker
f924e97269
Fix #71542: disk_total_space does not work with relative paths
For ZTS builds, we need to expand the path given to `disk_free_space()`
and `disk_total_space()` to properly support the VCWD.

Closes GH-7377.
2021-08-17 11:29:33 +02:00
Nikita Popov
47ccdecf00 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81353
2021-08-16 15:04:57 +02:00
Nikita Popov
d1e956ff31 Fixed bug #81353
A user-defined error handler should not be invoked for preload
warnings. We are in a partially shut-down state at that point.
2021-08-16 15:04:17 +02:00
Christoph M. Becker
2c6177a4a8
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81351: xml_parse may fail, but has no error code
2021-08-13 17:37:36 +02:00
Christoph M. Becker
80a377e69b
Fix #81351: xml_parse may fail, but has no error code
The fix for bug #73151[1] cured the symptoms, but not the root cause,
namely xmlParse() must not be called recursively.  Since that bugfix
also messed up the error handling, we basically revert it (but also
simplify the return), and then prevent calling the parser recursively.

[1] <f2a8a8c068>

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-7363.
2021-08-13 17:33:58 +02:00
Nikita Popov
1c6df2dffd Fixed bug #81192
Normally the filename is the current filename, but when traits
are involved, it might be a different one.
2021-08-12 14:35:13 +02:00
Nikita Popov
4a4ae45a0b Fix bug #81142 by adding zend_string_init_existing_interned()
Add a new interned string handler that fetches an interned string
if it exists, but does not create one if it does not (and instead
returns a non-interned string).

This fixes bug #81142, by preventing the creating of new interned
strings for unserialized array keys.

Closes GH-7360.
2021-08-12 11:57:50 +02:00
Philip Hofstetter
ace8fba759 Fix bug #81343: inconsistent type conversion after closeCursor
S->cols is already freed in the statement destructor and since
caa710037e the column data is only
populated on the first execute() which means that on subsequent
execute()s after closeCursor was called, all meta-data for column types
was removed and never restored

Closes GH-7355.
2021-08-11 18:24:13 +02:00
Remi Collet
1100a079ed
NEWS 2021-08-11 14:21:18 +02:00
Remi Collet
5d57d9073c
NEWS 2021-08-11 13:04:23 +02:00
Nikita Popov
28500fe4ef Fixed bug #81349
The ascii to wchar was reporting errors using conv_illegal_output,
while it should have been using WCSGROUP_THROUGH. Effectively that
replaced illegal characters with '?' for the purpose of
identification.
2021-08-11 11:37:02 +02:00
Joe Watkins
a2e051921a
Fix bug #81280 refuse to allow unicode chars in prompts 2021-08-11 10:35:00 +02:00
Nikita Popov
607be654fd Fixed bug #81342
Allow arbitrary whitespace, not just horizontal spaces.
2021-08-10 17:11:40 +02:00
Christoph M. Becker
a2b92d6baa
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81346: Non-seekable streams don't update position after write
2021-08-10 16:50:36 +02:00
Christoph M. Becker
4a1af1f871
Fix #81346: Non-seekable streams don't update position after write
The stream position is not related to the buffer, and needs to be
updated for non-seekable streams as well.  The erroneous condition
around the position update is a relict of an old commit[1].

The unexpected test expectation is due to bug #81345.

[1] <088e2692c3>

Closes GH-7356.
2021-08-10 16:49:07 +02:00
Christoph M. Becker
2e71c94c9b
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81302: Stream position after stream filter removed
2021-08-10 16:41:14 +02:00
Christoph M. Becker
40b31fcc80
Fix #81302: Stream position after stream filter removed
When flushing the stream filters actually causes data to be written to
the stream, we need to update its position, because that is not done by
the streams' write methods.

Closes GH-7354.
2021-08-10 16:39:55 +02:00
Gabriel Caruso
00bb7c97f8
Prepare for PHP 8.0.11 2021-08-10 11:46:56 +02:00
Derick Rethans
79d564a8cc Prepare for 7.4.24 2021-08-10 10:14:36 +01:00
Christoph M. Becker
606829f31f
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74544: Integer overflow in mysqli_real_escape_string()
2021-08-10 00:06:58 +02:00
Christoph M. Becker
5977610de1
Fix #74544: Integer overflow in mysqli_real_escape_string()
The patch has been provided by @johannes.

Closes GH-7353.
2021-08-10 00:05:39 +02:00
Derick Rethans
d9c8e5a42e Fixed bug #80963: DateTimeZone::getTransitions() truncated 2021-08-08 17:27:21 +01:00
Derick Rethans
66ea59e38e Import timelib 2021.07
Fixes:
- Bug #80998 (Missing second with inverted interval). (Derick)
- Bug #81106 (Regression in 8.1: add() now truncate ->f). (Derick)
2021-08-08 17:22:06 +01:00
Derick Rethans
8426623521 Upgrade timelib to 2021.06
Fixes among others:
. Bug #79580 (date_create_from_format misses leap year).
. Bug #80974 (Wrong diff between 2 dates in different timezones).
. Bug #81097 (DateTimeZone silently falls back to UTC when providing an offset with seconds).
. Bug #81273 (Date interval calculation not correct).
2021-08-08 13:41:33 +01:00
Derick Rethans
4aeff60f34 Upgrade timelib to version 2020.03 2021-08-08 12:11:18 +01:00
Christoph M. Becker
5628afb782
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81327: Error build openssl extension on php 7.4.22
2021-08-04 18:44:06 +02:00
Christoph M. Becker
6724d5d4c2
Fix #81327: Error build openssl extension on php 7.4.22
The recent fix for bug 52093 is not compatible with LibreSSL ≥ 2.7.0,
which we recognize as mostly OpenSSL 1.1.0 compatible, but they still
do not support `ASN1_INTEGER_set_int64()`.

Closes GH-7339.
2021-08-04 18:41:04 +02:00
Christoph M. Becker
213ad544e4
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #51498: imagefilledellipse does not work for large circles
2021-08-03 16:20:16 +02:00
Christoph M. Becker
c565555f03
Fix #51498: imagefilledellipse does not work for large circles
We backport the respective upstream fix[1].

[1] <ace7fd88dc>

Closes GH-7329.
2021-08-03 16:17:47 +02:00
Ben Ramsey
d23e601286
The master branch is now for 8.1.0beta3 2021-08-03 08:36:49 -05:00
Remi Collet
98b9d6d9c6
NEWS 2021-08-03 12:08:27 +02:00
Remi Collet
35c3e0b1a4
NEWS 2021-08-03 12:07:46 +02:00
Joe Watkins
05ef6334cd
Fix bug #81303 improve match errors 2021-08-02 17:31:26 +02:00
Christoph M. Becker
4645a9d10f
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81305: Built-in Webserver Drops Requests With "Upgrade" Header
2021-07-29 13:28:52 +02:00
Christoph M. Becker
d1ccb5bd0c
Fix #81305: Built-in Webserver Drops Requests With "Upgrade" Header
While our HTTP parser supports upgrade requests, the code using it does
not.  Since upgrade requests are only valid for HTTP/1.1 and we neither
support any higher version, nor HTTPS yet, we do not exit early in case
of such requests, i.e. we ignore them, what is allowed by the specs.

We keep the supporting code in case we can meaningfully support upgrade
requests in the future.

Closes GH-7316.
2021-07-29 13:16:15 +02:00
Christoph M. Becker
3244e0785d
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81252: PDO_ODBC doesn't account for SQL_NO_TOTAL
2021-07-28 10:53:27 +02:00
Christoph M. Becker
98049e8b9a
Fix #81252: PDO_ODBC doesn't account for SQL_NO_TOTAL
If `P->len` is negative (not only when it is `SQL_NULL_DATA`), we must
not go on, because the following code can't deal with that.  This means
that the output parameter will be set to `NULL` without any indication
what went wrong, but it's still better than crashing.

Closes GH-7295.
2021-07-28 10:51:38 +02:00
Nikita Popov
9d0db2e98a Fixed bug #81298
Creation of the filter may fail for some special encodings, for
which detection is not supported.
2021-07-28 10:11:46 +02:00
Christoph M. Becker
bf9afc184f
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81294: Segfault when removing a filter
2021-07-27 12:14:22 +02:00
Christoph M. Becker
1fa26eccba
Fix #81294: Segfault when removing a filter
We need to call the proper method.

Closes GH-7308.
2021-07-27 12:12:02 +02:00
Christoph M. Becker
71879d385e
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81283: shmop can't read beyond 2147483647 bytes
2021-07-23 17:49:56 +02:00
Christoph M. Becker
387c0de983
Fix #81283: shmop can't read beyond 2147483647 bytes
`start`, `count` and `shmop->size` are `zend_long`, so we must not
restrict to `INT_MAX`.

Closes GH-7301.
2021-07-23 17:46:42 +02:00
Nikita Popov
90ee1c36d7 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #66719
2021-07-23 11:24:59 +02:00
Nikita Popov
dfd05da97f Fix bug #66719
While parent:: should inherit the called scope, it should only do
so if it is compatible. If there is no called scope, or it is not
a subtype of the scope, we should fall back to the scope.
2021-07-23 11:24:22 +02:00
Nikita Popov
338a47bb85 Fix bug #63327
Use ZEND_MM_ALIGNED_SIZE for the extra size information.
I don't have a relevant system to test, but this should fix the
issue as long as required alignment is detected correctly.
2021-07-23 10:29:44 +02:00
Nikita Popov
5ac55af5e5 Add test for bug #80564
This has also been fixed by 3eb97a4566.
2021-07-23 09:45:39 +02:00
Nikita Popov
3eb97a4566 Always use separate static_members_table
When running without opcache, static_members_table is shared with
default_static_members_table. This is visible in reflection output,
because ReflectionProperty::getDefaultValue() will return the
current value, rather than the default value.

Address this by never sharing the table, which matches the behavior
we already see under opcache.

Fixes bug #80821.

Closes GH-7299.
2021-07-23 09:29:32 +02:00
Dmitry Stogov
053c56f52e Fixed bug #81226 (Integer overflow behavior is different with JIT enabled) 2021-07-21 19:28:43 +03:00
Christoph M. Becker
f03e7c845e
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74960: Heap buffer overflow via str_repeat
2021-07-21 15:33:17 +02:00
Christoph M. Becker
760ff841a1
Fix #74960: Heap buffer overflow via str_repeat
Trying to allocate a `zend_string` with a length only slighty smaller
than `SIZE_MAX` causes an integer overflow, so callers may need to
check that explicitly.  To make that easy in a portable way, we
introduce `ZSTR_MAX_LEN`.

Closes GH-7294.
2021-07-21 15:31:37 +02:00
Dmitry Stogov
a3a74b07e5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed Bug #80959 (infinite loop in building cfg during JIT compilation)
2021-07-21 14:34:04 +03:00
Dmitry Stogov
a9991fbf28 Fixed Bug #80959 (infinite loop in building cfg during JIT compilation) 2021-07-21 14:32:44 +03:00
Dmitry Stogov
4cf7a25856 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed Bug #81255 (Memory leak in PHPUnit with functional JIT)
2021-07-20 22:17:41 +03:00
Dmitry Stogov
02acc5ad3b Fixed Bug #81255 (Memory leak in PHPUnit with functional JIT) 2021-07-20 22:14:32 +03:00
Ben Ramsey
718b675fb6
The master branch is now for 8.1.0beta2 2021-07-20 11:13:28 -05:00
Nikita Popov
051ff33660 Fix bug #81272: Fix func info for functions returning EMPTY_ARRAY
The empty array has refcount > 1, so we should indicate this in
func info. In most cases this renders the func info redundant,
so drop it entirely.
2021-07-20 14:40:17 +02:00
Dmitry Stogov
1e4095f03d Fixed bug #81256 (Assertion `zv != ((void *)0)' failed for "preload" with JIT) 2021-07-20 15:27:43 +03:00
Christoph M. Becker
18abfcb306
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Revert "Fix #79908: json_encode encodes negative zero as int"
2021-07-20 00:28:27 +02:00
Christoph M. Becker
2d2c001ca5
Revert "Fix #79908: json_encode encodes negative zero as int"
This reverts commit 717f1ed5e4.
2021-07-20 00:25:50 +02:00
Christoph M. Becker
ef77d3c89f
Fix #81206: Multiple PHP processes crash with JIT enabled
We need to avoid resetting the JIT for all SAPIs, but we need to
initialize the JIT handlers even when only reattaching on Windows.

Closes GH-7208.
2021-07-19 23:45:37 +02:00
Nikita Popov
814a932734 Add ZEND_ACC_NOT_SERIALIZABLE flag
This prevents serialization and unserialization of a class and its
children in a way that does not depend on the zend_class_serialize_deny
and zend_class_unserialize_deny handlers that will be going away
in PHP 9 together with the Serializable interface.

In stubs, `@not-serializable` can be used to set this flag.

This patch only uses the new flag for a handful of Zend classes,
converting the remainder is left for later.

Closes GH-7249.
Fixes bug #81111.
2021-07-19 15:59:11 +02:00
Dmitry Stogov
66328742ea Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81249 (Intermittent property assignment failure with JIT enabled)
2021-07-19 12:14:55 +03:00
Dmitry Stogov
c0e4932816 Fixed bug #81249 (Intermittent property assignment failure with JIT enabled) 2021-07-19 12:11:09 +03:00
Dmitry Stogov
3621ce60e4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81225 (Wrong result with pow operator with JIT enabled)
2021-07-19 10:43:08 +03:00
Dmitry Stogov
9cd437138e Fixed bug #81225 (Wrong result with pow operator with JIT enabled) 2021-07-19 10:39:52 +03:00
Christoph M. Becker
9fbcaa57aa
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #78238: BCMath returns "-0"
2021-07-16 15:56:15 +02:00
Christoph M. Becker
bcb89c75ec
Fix #78238: BCMath returns "-0"
There is no negative zero in the decimal system, so we must suppress
the sign.

Closes GH-7250.
2021-07-16 15:54:24 +02:00
Nikita Popov
12a858ac95 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #81265: getimagesize returns 0 for 256px ICO images
2021-07-16 10:07:26 +02:00
George Dietrich
8f97f82e35 Fix bug #81265: getimagesize returns 0 for 256px ICO images
Set ICO height/width to 256 if 0.
2021-07-16 10:05:58 +02:00
Christoph M. Becker
bb4dbbc150
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80849: HTTP Status header truncation
2021-07-15 19:13:58 +02:00
Christoph M. Becker
a054ef2aad
Fix #80849: HTTP Status header truncation
While truncating the contents of a header is okay, we must never omit
the trailing CRLF.

Closes GH-7238.
2021-07-15 19:10:53 +02:00
Christoph M. Becker
c6b7f6c39f
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #72595: php_output_handler_append illegal write access
2021-07-15 15:29:48 +02:00
Christoph M. Becker
a942cf5b02
Fix #72595: php_output_handler_append illegal write access
We must make sure that `handler->buffer.size + grow_max` does not
overflow, so we're using `safe_erealloc()` instead.

Closes GH-7241.
2021-07-15 15:26:42 +02:00
Christoph M. Becker
c0a1ef3e32
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #72146: Integer overflow on substr_replace
2021-07-15 12:56:12 +02:00
Christoph M. Becker
33f8dfb15a
Fix #72146: Integer overflow on substr_replace
Adding two `zend_long`s may overflow, and casting `size_t` to
`zend_long` may truncate; we can avoid this here by enforcing unsigned
arithmetic.

Closes GH-7240.
2021-07-15 12:54:28 +02:00
Derick Rethans
f40dcedb48 Update NEWS for 7.4.22 2021-07-13 17:21:34 +01:00
Sara Golemon
7dc35ac8a7
Bump to 8.0.10 2021-07-13 14:10:35 +00:00
Joe Watkins
6a9daafed4
Fix bug #81237 comparison of fake closures doesn't work 2021-07-13 15:35:55 +02:00
Christoph M. Becker
1ba190bdb3
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #79908: json_encode encodes negative zero as int
2021-07-13 15:32:32 +02:00
Christoph M. Becker
717f1ed5e4
Fix #79908: json_encode encodes negative zero as int
Encoding a negative zero as `-0` is likely to loose the sign when
decoding (at least it does with `json_decode()`).  Therefore, we encode
it as if `JSON_PRESERVE_ZERO_FRACTION` was specified, i.e. as `-0.0`.

Closes GH-7234.
2021-07-13 15:31:07 +02:00
Christoph M. Becker
0c0ecf0470
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #73226: --r[fcez] always return zero exit code
2021-07-12 23:12:19 +02:00
Christoph M. Becker
9db3eda2cb
Fix #73226: --r[fcez] always return zero exit code
This makes the behavior consistent with `--ri`, and is likely useful
for scripting.

Closes GH-7221.
2021-07-12 23:09:28 +02:00
Christoph M. Becker
5fb5a739e2
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81243: Too much memory is allocated for preg_replace()
2021-07-12 18:35:49 +02:00
Christoph M. Becker
a6b43086e6
Fix #81243: Too much memory is allocated for preg_replace()
Trimming a potentially over-allocated string appears to be reasonable,
so we drop the condition altogether.

We also re-allocate twice the size needed in the first place, and not
roughly tripple the size.

Closes GH-7231.
2021-07-12 18:33:55 +02:00
Aaron Piotrowski
8fd747a2a0
Fiber ucontext support (#7226)
Co-authored-by: Martin Schröder <m.schroeder2007@gmail.com>
2021-07-11 15:40:11 -05:00
Benjamin Eberlei
bc39abe8c3 Fix #80097: Have ReflectionAttribute implement Reflector and __toString
Implement printing for ReflectionAttribute. Attributes aren't
printed as part of reflection output for other structures (classes
etc) yet.

Closes GH-6117.
2021-07-07 12:42:04 +02:00
Ben Ramsey
c6d4f60827
The master branch is now for 8.1.0beta1 2021-07-06 10:23:32 -05:00
Christoph M. Becker
d776413f0b
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81223: flock() only locks first byte of file
2021-07-06 12:00:09 +02:00
Christoph M. Becker
520c00a5bf
Fix #81223: flock() only locks first byte of file
`flock()` should lock the whole file, like on other systems which use
mandatory locking.  We cannot use `0` like for `flck.l_len`, so we use
the largest number, what is valid according to the documentation:
<https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-lockfileex#remarks>.

Closes GH-7216.
2021-07-06 11:58:02 +02:00
Christoph M. Becker
8071bd2faf
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74264: grapheme_strrpos() broken for negative offsets
2021-07-05 18:15:24 +02:00
Christoph M. Becker
28c9376306
Fix #74264: grapheme_strrpos() broken for negative offsets
We must not assume that `usearch_last()` gives the proper result for
negative offsets.  Instead we'd need to continue to search backwards
(`usearch_previous`) until we find a proper match.  However, apparently
searching backwards is broken, so we work around by searching forward
from the start of the string until we pass the `offset_pos`, and then
use the previous result.

Closes GH-7189.
2021-07-05 18:11:30 +02:00
Nikita Popov
52cf7ab8a2 Fix bug #80072: Root live tmpvars after GC
TMPVAR operands are destroyed using zval_ptr_dtor_nogc(), because
they usually cannot contain cycles. However, there are some rare
exceptions where this is possible, e.g. unserialize() return value.
In such cases we rely on the producing code to root the value. If
a GC run occurs between the rooting and consumption of the value,
we would end up leaking it. To avoid this, root all live TMPVAR
values after a GC run.

Closes GH-7210.
2021-07-02 15:28:36 +02:00
Nikita Popov
4e66e6a73a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80173
2021-07-02 10:08:40 +02:00
Nikita Popov
bdc60fa7da Fixed bug #80173
The analysis in the bug report wasn't correct (at least not in
this case -- there may still be a more general problem here),
the issue was that write_property returned the original variable_ptr
rather than the zend_assign_to_variable() return value, which will
DEREF the variable before overwriting it.
2021-07-02 10:07:40 +02:00
Christoph M. Becker
5b0a46908c
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #52093: openssl_csr_sign truncates $serial
2021-07-01 15:43:52 +02:00
Christoph M. Becker
334387bb70
Fix #52093: openssl_csr_sign truncates $serial
We use `ASN1_INTEGER_set_int64()` if supported[1], to avoid the
truncation of the integer.

[1] <https://www.openssl.org/docs/man1.1.0/man3/ASN1_INTEGER_set_int64.html#HISTORY>

Closes GH-7209.
2021-07-01 15:42:02 +02:00
Nikita Popov
b976bc44f1 Fixed bug #81208
The number of populated positional arguments is argc. i may also
include named args and thus try to dtor uninitialized zvals.
2021-07-01 13:36:57 +02:00
Christoph M. Becker
70b0330e53
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #73630: Built-in Weberver - overwrite $_SERVER['request_uri']
2021-06-30 16:15:50 +02:00
Christoph M. Becker
d7db5701a3
Fix #73630: Built-in Weberver - overwrite $_SERVER['request_uri']
The built-in Webserver's `on_path`, `on_query_string` and `on_url`
callbacks may be called multiple times from the parser; we must not
simply replace the old values, but need to concatenate the new values
instead.

This appears to be tricky for `on_path` due to the path normalization,
so we fail if the function is called again.

The built-in Webserver logs errors during request parsing to stderr,
but this is ignored by the php_cli_server framework, and apparently the
Webserver does not send a resonse at all in such cases (instead of an
4xx).  Thus we can only check that a request with an overly long path
fails.

Closes GH-7207.
2021-06-30 16:13:08 +02:00
Nikita Popov
65bd8d281f Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #80728: Don't reset the timeout on ini deactivate
2021-06-29 16:37:27 +02:00
Calvin Buckley
98a21d1dfb Fix bug #80728: Don't reset the timeout on ini deactivate
When the time limit for a script is changed, when the script ends,
its INI value will be reset. This calls the event handler for the
timeout change, which will unset then reset the timeout. However,
this is done even if the script is done executing, and say, the CGI
or CLI web server process is idle.

This is probably incorrect, but isn't a problem on most platforms,
because PHP uses a timer that only ticks when the process is active
(that is, executing code). Since when it's idle, it's blocking on
listen/read, it won't tick because nothing executes. However, on
platforms where only the real-time timer is supported, (Cygwin/PASE)
it ticks regardless of if PHP is even executing. This means that the
idle processes are subject to timeouts from the INI reset on script
end.

This makes it so the timer is never set if the state is deactivating.
Testing with the CLI web server indicates the timer no longer
spuriously activates under PASE.

Closes GH-6683.
2021-06-29 16:36:46 +02:00
Christoph M. Becker
53ea910d17
7.3.30 is next 2021-06-29 14:14:53 +02:00
Christoph M. Becker
f5cba2d491
[ci skip] Fix NEWS format 2021-06-29 10:28:35 +02:00
Christoph M. Becker
1bf2b04b26
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #68471: IntlDateFormatter fails for "GMT+00:00" timezone
2021-06-28 13:55:56 +02:00
Christoph M. Becker
1a01f7816c
Fix #68471: IntlDateFormatter fails for "GMT+00:00" timezone
GMT+00:00 is recognized by ICU, and is normalized to GMT.  There are no
issues when GMT+00:00 is passed to `IntlTimeZone::createTimeZone()`,
but passing it to IntlDateFormatter::__construct() causes a failure,
since there is an additional check regarding the validity.  While
checking the validity of the result of `TimeZone::createTimeZone()`[1]
is a good idea, comparing the IDs is overly restrictive.  Instead we
just check that the timezone is supported by ICU.

[1] <https://unicode-org.github.io/icu-docs/apidoc/dev/icu4c/classicu_1_1TimeZone.html#a35da0507b62754ffe5d8d59c19775cdb>

Closes GH-7190.
2021-06-28 13:54:22 +02:00
Cameron Porter
b11785c5e4 Fixed bug #81085: Add version 7.71.0 blob options.
Adds support for the following options beginning with version 7.71.0:

    CURLOPT_ISSUERCERT_BLOB
    CURLOPT_PROXY_ISSUERCERT
    CURLOPT_PROXY_ISSUERCERT_BLOB
    CURLOPT_PROXY_SSLCERT_BLOB
    CURLOPT_PROXY_SSLKEY_BLOB
    CURLOPT_SSLCERT_BLOB
    CURLOPT_SSLKEY_BLOB

Closes GH-7194.
2021-06-28 09:54:45 +02:00
Joe Watkins
aad0d26816
Fix bug #81200 ReflectionMethod::isStatic belongs on ReflectionFunctionAbstract 2021-06-28 09:49:30 +02:00
Joe Watkins
39a54e2c31
Fix #81202 powerpc64 build fails on fibers 2021-06-26 15:39:39 +02:00
Ben Ramsey
ac82c00640
The master branch is now for 8.1.0alpha3 2021-06-22 10:29:17 -05:00
Stanislav Malyshev
c68a687566
Update NEWS 2021-06-20 22:20:38 -07:00
Anatol Belski
2b948720ab
NEWS: Add bug #81101 note
[ci skip]

Signed-off-by: Anatol Belski <ab@php.net>
2021-06-19 16:54:11 +02:00
Anatol Belski
4d8eb892b9
NEWS: Add bug #81101 note
[ci skip]

Signed-off-by: Anatol Belski <ab@php.net>
2021-06-19 16:51:13 +02:00
George Peter Banyard
f0fd5922ee
Fix bug #81159: Object to int warning when using an object as a string offset
Closes GH-7167
2021-06-18 18:07:22 +01:00
Joe Watkins
ed88daecf4
missing news/upgrading entry 2021-06-18 11:25:36 +02:00
Joe Watkins
7bf930d014
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #81163 indirect vars in __sleep
2021-06-18 11:17:03 +02:00
Joe Watkins
bc59b046c6
Fix bug #81163 indirect vars in __sleep 2021-06-18 11:16:26 +02:00
Christoph M. Becker
8daed6d0f2
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81145: copy() and stream_copy_to_stream() fail for +4GB files
2021-06-17 13:16:30 +02:00
Christoph M. Becker
2555efadbc
Fix #81145: copy() and stream_copy_to_stream() fail for +4GB files
When mapping the file, we need to pass the proper `dwFileOffsetHigh`
instead of `0`.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-7158.
2021-06-17 13:13:47 +02:00
Christoph M. Becker
13f3999a77
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #72809: Locale::lookup() wrong result with canonicalize option
2021-06-16 10:36:51 +02:00
Christoph M. Becker
0f1b17e378
Fix #72809: Locale::lookup() wrong result with canonicalize option
Canonicalization converts the locale to ICU format[1].  However, the
lookup described in RFC 4647, section 3.4, is about POSIX format.  To
make that lookup work for ICU format, we also need to cater to keyword
separators.

The results are somewhat unexpected, but apparently canonical lookup is
explicitly supposed to return canonical language tags[2].

[1] <https://unicode-org.github.io/icu/userguide/locale/#canonicalization>
[2] <https://github.com/php/php-src/blob/php-7.4.20/ext/intl/locale/locale_methods.c#L1504>

Closes GH-7151.
2021-06-16 10:33:59 +02:00
Derick Rethans
8370a084e4 Prepare for 7.4.22 2021-06-15 19:52:02 +01:00
Gabriel Caruso
b81c3b5b1c
Prepare for PHP 8.0.9 2021-06-15 09:19:13 +02:00
Joe Watkins
72c0deb400
Revert "hrtime implementation update for Mac"
This reverts commit a3e55286a6.

    This commit broke the build for OSX before Sierra.

    The apple documentation states the equivalent uses raw uptime, and
    the source code of the non portable function says raw uptime would
    call the same routine we were calling before this commit.

    Since the correct version of this commit - according to docs -
    would bring no value whatsoever, and this version breaks the build
    there doesn't seem any sense in making this change.
2021-06-14 14:27:35 +02:00
Joe Watkins
a297c66cfb
Fix #81136 opcache header not installed, causing shared build to fail 2021-06-14 11:09:36 +02:00
Nikita Popov
5dc31e0cb6 Fixed bug #80197
Use "libmagic/magic.h" rather than <magic.h> to make sure that we
use the bundled libmagic, even if there is a system libmagic on the
include path.
2021-06-14 10:59:13 +02:00
Nikita Popov
71fb83567f Fix bug #80945: Don't throw undefined array key warning in ArrayObject unset()
This makes the behavior of ArrayObject the same as far plain
arrays, which don't throw a warning when unsetting a key that
already doesn't exit.
2021-06-14 10:14:38 +02:00
Nikita Popov
805471e86b Fix bug #81112: Implement JsonSerializable for SplFixedArray
This returns an array for SplFixedArray JSON encoding, which
is more appropriate than an object with integer string keys.

Closes GH-7117.
2021-06-14 10:07:45 +02:00
Joe Watkins
f0755718e3
Merge branch '81135'
* 81135:
  Fix #81135 unknown help topic in phpdbg fails assertion
2021-06-13 22:21:07 +02:00
Joe Watkins
c29226581e
Set BUILD_CC for phpize 2021-06-13 16:25:41 +02:00
Joe Watkins
69520ab619
fix news 2021-06-13 16:21:28 +02:00
Christoph M. Becker
21f2ff79de
Fix #81120: PGO data for main PHP DLL are not used
We need to look for the right file.  To avoid total confusion, we also
rename the variables; however, the right solution would have been to
drop the version suffixes, since they don't help (major + minor maybe,
but not major only).
2021-06-10 22:57:09 +02:00
Nikita Popov
087773879f Fix bug #81119
The implementation for functions and operators is shared. However,
we should not be generating argument errors for operators.
2021-06-10 14:47:36 +02:00
Christopher Jones
c9cfef6abd
Update NEWS for #77120 2021-06-10 10:18:57 +10:00
Patrick Allaert
87068aead9
Preparing for alpha2 2021-06-08 18:24:06 +02:00
Christoph M. Becker
902ec698eb
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81092: fflush before stream_filter_remove corrupts stream
2021-06-08 15:38:57 +02:00
Christoph M. Becker
a1738d8bd1
Fix #81092: fflush before stream_filter_remove corrupts stream
When doing a non finishing flush, BZ2_bzCompress() returns BZ_FLUSH_OK
(not BZ_FINISH_OK) what requires us to do further flushes right away.

We also refactor the while-loop as do-loop.

Closes GH-7113.
2021-06-08 15:36:37 +02:00
Joe Watkins
27ce269c1b
Revert "Fix bug #24214 implement access to skip_last in user API for backtrace"
This reverts commit a5cef84de8.
2021-06-08 11:30:37 +02:00
Joe Watkins
a5cef84de8
Fix bug #24214 implement access to skip_last in user API for backtrace 2021-06-06 08:37:32 +02:00
Joe Watkins
5c3cb3583b
Merge branch 'PHP-8.0'
* PHP-8.0:
  fix bug #72998
2021-06-03 10:34:00 +02:00
Joe Watkins
1143155fcb
fix bug #72998
the function fn_complete in libedit null checks matches[2]
2021-06-03 10:33:10 +02:00
Nikita Popov
324ad2f42c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81070

This is a non-trivial merge. To avoid an ABI break, a new
zend_set_memory_limit_ex() function is added.
2021-05-31 15:24:00 +02:00
Peter van Dommelen
1b3b5c94e5 Fixed bug #81070
When the memory limit is reduced using an `ini_set("memory_limit", ..)`
below the currently allocated memory, the out-of-memory check overflowed.
Instead of implementing additional checks during allocation,
`zend_set_memory_limit()` now validates the new memory limit. When
below the current memory usage the ini_set call will fail and throw
a warning.

This is part of GH-7040.
2021-05-31 15:18:58 +02:00
Christoph M. Becker
108105b2c6
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #76694: native Windows cert verification uses CN as sever name
2021-05-31 14:36:57 +02:00
Christoph M. Becker
7fd48264de
Fix #76694: native Windows cert verification uses CN as sever name
This is not guaranteed to work, since the actual server name may only
be given as SAN.  Since we're doing the peer verification later anyway
(using the respective context options as appropriate), there is no need
to even supply a server name when verifying against the Windows cert
store.

Closes GH-7060.
2021-05-31 14:35:17 +02:00
Nikita Popov
ee74f2e57f Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81090
2021-05-31 12:33:59 +02:00
Nikita Popov
82f6f6da67 Fixed bug #81090
For concatenation, the in-place variant can be much more efficient,
because it will reallocate the string in-place. Special-case the
typed property compound assignment code for the case where we
concatenate to a string, in which case we know that the result
will also be a string, and we don't need the type check anyway.
2021-05-31 12:31:56 +02:00
Anatol Belski
805b391d99
NEWS: UPGRADING.INTERNALS: Add PCRE2 10.37 info
[ci skip]

Signed-off-by: Anatol Belski <ab@php.net>
2021-05-30 13:06:16 +02:00
Máté Kocsis
a0af84bebd
Fixed bug #81088 error in regression test for oci_fetch_object() and oci_fetch_array()
Closes GH-7072
2021-05-28 17:56:51 +02:00
Nikita Popov
635303aec5 Fixed bug #80761
When row data split across multiple packets, allocate a temporary
buffer that can be reallocated, and only copy into the row buffer
pool arena once we know the final size. This avoids quadratic
memory usage for very large results.

(cherry picked from commit 1fc4c89214)
2021-05-27 16:00:03 +02:00
Dmitry Stogov
ac65f6af6e Fixed bug #81051 (Broken property type handling after incrementing reference) 2021-05-27 15:22:34 +03:00
Christoph M. Becker
a5601b2ab5
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #76359: open_basedir bypass through adding ".."
2021-05-25 13:46:38 +02:00
Christoph M. Becker
ee9e07541f
Fix #76359: open_basedir bypass through adding ".."
We explicitly forbid adding paths with a leading `..` to `open_basedir`
at runtime.

Closes GH-7024.
2021-05-25 13:44:53 +02:00
Nikita Popov
0fb371440d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #81068: Fix possible use-after-free in realpath_cache_clean()
2021-05-25 11:40:57 +02:00
Dimitry Andric
99a208566a Fix bug #81068: Fix possible use-after-free in realpath_cache_clean()
If ZTS is enabled, this can cause cwd_globals_ctor() to be called
multiple times, each with a freshly allocated virtual_cwd_globals
instance. At shutdown time however, cwd_globals_dtor() will call
realpath_cache_clean(), which then possibly cleans up the same
realpath_cache instance more than once. Using AddressSanitzer, this
shows up as a heap use-after-free.

To avoid this, add a helper function to do the actual work on one
instance of a realpath_cache, and call it both from cwd_globals_dtor()
and realpath_cache_clean(). The former uses the virtual_cwd_globals
parameter passed in via the destructor, the latter uses the CWDG()
macro.
2021-05-25 11:40:28 +02:00
Joe Watkins
531413f809
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81076 Invalid implicit binds cause incorrect count in static vars of closure debug info
2021-05-25 11:27:20 +02:00
Joe Watkins
213063f6ca
Fix #81076 Invalid implicit binds cause incorrect count in static vars of closure debug info 2021-05-25 11:26:38 +02:00
Joe Watkins
6408ebb731
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #77627 method_exists on Closure::__invoke
2021-05-25 11:23:08 +02:00
Joe Watkins
cfd4d3df0b
Fix #77627 method_exists on Closure::__invoke 2021-05-25 11:22:05 +02:00
Joe Watkins
b227a72285
ReflectionFunctionAbstract::getClosureUsedVariables
Make a distinction at compile time between bind types for static
  variables

  getStaticVariables remains unchanged

  Fixes #80071
2021-05-21 15:25:35 +02:00
Dmitry Stogov
6e2d47e071 Fixed bug #80968 (JIT segfault with return from required file) 2021-05-20 16:45:24 +03:00
Sara Golemon
64918fee97
Prep for 8.0.8 2021-05-19 19:18:56 +00:00
Christoph M. Becker
5dfdd694e7
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81048: phpinfo(INFO_VARIABLES) "Array to string conversion"
2021-05-19 14:09:21 +02:00
Christoph M. Becker
36b9bdeeec
Fix #81048: phpinfo(INFO_VARIABLES) "Array to string conversion"
Now that we properly dereference references of the superglobals. we
also need to dereference contained references to avoid to string
conversion.

Closes GH-7014.
2021-05-19 14:07:15 +02:00
Derick Rethans
3938bfb564 The PHP 7.4 branch is now for 7.4.21 2021-05-18 13:44:01 +01:00
Christoph M. Becker
6c3896b1e9
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  [ci skip] Removed incorrect news entry
2021-05-18 12:36:21 +02:00
Graham Campbell
66c3a174f5
[ci skip] Removed incorrect news entry
Closes GH-7007.
2021-05-18 12:34:46 +02:00
Nikita Popov
0bff67c0ab Fixed bug #81019
Before the zval -> zend_object migration, this code used macros
like FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK, which internally
clear the error. Now that they are no longer used, we need to
manually clear the error.
2021-05-17 16:33:35 +02:00
Nikita Popov
c446d68f7c Fixed bug #81046
Literal compaction was incorrectly assuming that literals with
the same base literal and the same number of related literals
would be equal. Maybe that was the case historically, but at
least it isn't true in PHP 8, where FETCH_CONSTANT and INIT_METHOD
have distinct literals at the second position.

Fix this by making the cache key a concatenation of all literals,
rather than just the base literal. We still distinguish the number
of related literals based on a bias added to the string hash.
2021-05-17 15:46:49 +02:00
Kamil Tekiela
2a486d48ed
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix NEWS
2021-05-14 12:36:07 +01:00
Kamil Tekiela
5c164a2223
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix NEWS
2021-05-14 12:34:46 +01:00
Kamil Tekiela
ead72aabfb
Fix NEWS 2021-05-14 12:33:32 +01:00
Kamil Tekiela
dbfc9f99d1
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81037 PDO discards error message text from prepared statement

Closes GH-6978.
2021-05-14 12:04:22 +01:00
Kamil Tekiela
574b551567
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81037 PDO discards error message text from prepared statement
2021-05-14 11:59:36 +01:00
Kamil Tekiela
6afbb74194
Fixed bug #81037 PDO discards error message text from prepared statement 2021-05-14 11:54:49 +01:00
Christoph M. Becker
c455f49a6a
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81032: GD install is affected by external libgd installation
2021-05-14 12:26:40 +02:00