Commit Graph

13331 Commits

Author SHA1 Message Date
Bob Weinand
e6cf583160 Fix GH-8082: Prevent leaking memory on observed transient run_time_caches
This is achieved by tracking the observers on the run_time_cache (with a fixed amount of slots, 2 for each observer).
That way round, if the run_time_cache is freed all associated observer data is as well.

This approach has been chosen, as to avoid any ABI or API breakage.
Future versions may for example choose to provide a hookable API for run_time_cache freeing or similar.
2022-03-01 14:49:44 +01:00
Gabriel Caruso
05f2fb3af3
Fix NEWS format 2022-03-01 11:32:28 +01:00
Gabriel Caruso
5507201a38
Prepare for PHP 8.0.18 2022-03-01 11:30:01 +01:00
Christoph M. Becker
0d266a24d6
Fix GH-8080: ReflectionClass::getConstants() depends on def. order
When we need to evaluate constant ASTs, we always have to do that in
the scope where the constant has been defined, which may be a parent
of the `ReflectionClass`'s scope.

Closes GH-8106.
2022-02-28 10:08:47 +01:00
Christoph M. Becker
ef80dcb80b
Fix GH-8074: Wrong type inference of range() result
If either the first or second operand of `range()` may be a string, we
must not exclude the possibility that the result may be an array of
longs.

Closes GH-8131.
2022-02-22 10:14:54 +01:00
Kamil Tekiela
93a8d5cd17
Fix bug GH-8058 - mysqlnd segfault when prepare fails
Closes GH-8061
2022-02-14 11:45:17 +00:00
Till Backhaus
29fe06fa59
Fix bug #76109: Implement fpm_scoreboard_copy
fpm_scoreboard_copy locks the scoreboard while copying the scoreboard and all
proc scoreboards. proc scoreboards are locked one by one while copying each
struct. The old implementation (inside fpm_handle_status_request) only briefly
locked the scoreboard while copying the scorebard.

Closes GH-7931

Co-authored-by: Jakub Zelenka <bukka@php.net>
2022-02-09 23:02:45 +00:00
Brett
1d48da6da5
Fixed libpng warning when loading interlaced images
We enable interlace transform when reading png.

Closes GH-8002.
2022-02-08 10:46:50 +01:00
Christoph M. Becker
86c196ba7f
Fix GH-7980: Unexpected result for iconv_mime_decode
We need to reset the shift state right after conversion, to cater to
potenially following plain encodings.  Also, there is no need to reset
the shift for plain encodings, because these are not state-dependent.

Closes GH-8025.
2022-02-07 14:28:57 +01:00
David Carlier
bea542a953
Haiku fix ZTS build, disabling tls model
Closes GH-8047.
2022-02-07 13:05:54 +01:00
Christoph M. Becker
9bd468da63
Fix GH-7953: ob_clean() only does not set Content-Encoding
If an output handler has not yet been started, calling `ob_clean()`
causes it to start.  If that happens, we must not forget to set the
`Content-Encoding` and `Vary` headers.

Closes GH-7960.
2022-02-03 16:09:00 +01:00
Sara Golemon
8a46311dbd
Bump for 8.0.17-dev 2022-02-02 23:44:02 +00:00
David Carlier
07aaa34cd4
Fix GH-7978: sockets extension compilation errors
We fix the `ucred` detection when custom `CFLAGS` are in use.

Closes GH-7981.
2022-01-21 23:56:56 +01:00
Kamil Tekiela
5fc0db989e
Strip MariaDB 10 prefix
Closes GH-7972
2022-01-19 21:39:42 +00:00
Christoph M. Becker
03816fba46
Fix GH-7902: mb_send_mail may delimit headers with LF only
Email headers are supposed to be separated with CRLF. Period.

We introduce a `CRLF` macro for better comprehensibility right away.

Closes GH-7907.
2022-01-18 13:08:08 +01:00
Christoph M. Becker
93a3c71eb4
Fix GH-7896: Environment vars may be mangled on Windows
When bug 77574[1] has been fixed, the fix only catered to variables
retrieved via `getenv()` with a `$varname` passed, but neither to
`getenv()` without arguments nor to the general import of environment
variables into `$_ENV` and `$_SERVER`.  We catch up on this by using
`GetEnvironmentStringsW()` in `_php_import_environment_variables()` and
converting the encoding to whatever had been chosen by the user.

[1] <https://bugs.php.net/bug.php?id=75574>

Closes GH-7928.
2022-01-17 23:44:41 +01:00
Christoph M. Becker
478edcdacb
Fix GH-7875: mails are sent even if failure to log throws exception
We explicitly check for an exception after the logging attempt, and
bail out in that case.

Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>

Closes GH-7878.
2022-01-17 22:30:25 +01:00
Christoph M. Becker
703cac33db
Fix GH-7867: FFI::cast() from pointer to array is broken
Casting from pointer to array is special, so we must not fall back to
the general FFI casting.  There is a particular issue regarding the
size comparison, namely that the pointer size is always 8 for 64bit
architectures, but the size of an array is determined by its
declaration, so as is casting a pointer to an array with more than 8
elements would fail, but casting to an array with less than 9 elements
succeeds, but the internal pointer would point to some arbitrary
memory.

We fix this by properly supporting the cast.  An alternative would be
to deny this kind of cast generally, since it is not necessarily safe.
However, FFI isn't necessarily safe anyway.

We also check pointer/array type compatibility when casting.

Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes GH-7876.
2022-01-10 23:58:39 +01:00
Benjamin Eberlei
2f6a06ccb0
Fix #81430: Attribute instantiation leaves dangling pointer
By switching attribute constructor stackframe to be called via
trampoline the stack allocation is not causing dangling pointers
in the zend_observer API anymore.

Co-Authored-By: Florian Sowade <f.sowade@suora.com>
Co-Authored-By: Christopher Becker <cmbecker69@gmx.de>
Co-Authored-By: Dmitry Stogov <dmitry@zend.com>

Closes GH-7885.
2022-01-10 12:40:15 +01:00
David Carlier
c99a026c9c
Fix memory leak on invalid port
Closes GH-7911.
2022-01-08 21:04:55 +01:00
David Carlier
09165ace37
Fix ext/sockets build on Haiku
The `SOCK_RDM` datagram option is unsupported on Haiku; instead `ifreq`
has direct access to `ifr_index`.

Closes GH-7849.
2022-01-04 14:10:50 +01:00
Gabriel Caruso
d70c69839c
Prepare for PHP 8.0.16 2022-01-04 09:40:46 -03:00
NathanFreeman
b3903515bf
Fix bug where large bigints may be truncated
Unless stringified results are requested, we need to parse large
bigints as unsigned, to avoid wrap-around behavior.

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-7837.
2021-12-30 19:07:36 +01:00
Christoph M. Becker
ee610947ce
Revert "Fix zend_observer_fcall_end_all() accessing dangling pointers"
This reverts commit 76e2a8380e.  Cf.
<76e2a8380e (r62560239)>.
2021-12-27 21:08:51 +01:00
Florian Sowade
76e2a8380e
Fix zend_observer_fcall_end_all() accessing dangling pointers
This may happen, when the execute_data was allocated on the stack.  We
ensure that the runtime cache pointer is not NULL before dereferencing
it.

This is a partial fix for bug 81430.

Closes GH-7665.
2021-12-27 18:19:13 +01:00
Christoph M. Becker
fd3fc5c193
Fix GH-7826: Inconsistent argument name in hash_hmac_file and hash_file
Like `hash_file()`, `hash_hmac_file()` expects a filename, and not some
string data.  Fixing this now, constitutes a (hopefully small) BC break
though.

Closes GH-7828.
2021-12-26 12:55:53 +01:00
David Carlier
3f0bb67361
Avoid void* arithmetic in sockets/multicast.c on NetBSD
On NetBSD, ifconf.ifc_buf member, unlike most of platforms, is a void
pointer.

We also fix the cpuinfo declarations with empty parameter lists.

Closes GH-7819.
2021-12-23 16:17:30 +01:00
Yifan Tong
3587e13ab3
Fix FILTER_FLAG_NO_RES_RANGE flag
`2001:10::/28` is a reserved IPv6 range. But there's a typo in GH-7476,
which caused IPv6 address like `240b:0010::1` will be filtered by the
flag `FILTER_FLAG_NO_RES_RANGE`.

http://www.faqs.org/rfcs/rfc6890.html

Closes GH-7790.
2021-12-19 16:24:34 +01:00
Christoph M. Becker
49380b59d2
Fix #81679: Tracing JIT crashes on reattaching
When a new process reattaches to OPcache, tracing JIT causes segfaults,
because each new process allocates its own `zend_jit_traces` and
`zend_jit_exit_groups` in SHM, although these need to be shared between
all processes.

We solve that by only allocating these structs for the first process,
and store the pointers in `accel_shared_globals`, so we can reassign
them when a new process reattaches.

Closes GH-7776.
2021-12-15 15:37:23 +01:00
Christoph M. Becker
c435e67746
Fix GH-7765: php_oci_cleanup_global_handles segfaults at second call
We must not use the TSRM accessor macros in GINIT and GSHUTDOWN, but
rather use the passed pointers directly.  For simplicity, we inline
`php_oci_cleanup_global_handles()`, and also the `PHP_OCI_CALL()`
macros; the latter are unlikely to be needed here, but don't hurt.

Closes GH-7766.
2021-12-12 22:38:00 +01:00
Christoph M. Becker
0b3a937670
Fix GH-7759: Incorrect return types for hash() and hash_hmac()
`hash()` and `hash_hmac()` never return `false`; only `hash_file()` and
`hash_hmac_file()` return `false` in case the data cannot be read.

Closes GH-7760.
2021-12-12 15:39:55 +01:00
SATO Kentaro
778513f605
Fix error message allocation of PDO PgSQL
Closes GH-7723.
2021-12-12 15:17:36 +01:00
Christoph M. Becker
5675ebe649
Fix #81585: cached_chunks are not counted to real_size on shutdown
The amount of allocated system memory is kept in `real_size`, including
the allocated `cached_chunks`.  Thus, we need to keep the proper count
at the end of the shutdown.

Closes GH-7745.
2021-12-10 12:24:06 +01:00
Aliaksandr Bystry
daf79e2d91
Fix #75917: SplFileObject::seek broken with CSV flags
Closes GH-7697.
2021-12-06 18:59:48 +01:00
Michael Wallner
1f38c003d2 fix #81656: GCC-11 silently ignores -R
Closes GH-7688.
2021-12-05 21:06:28 +01:00
Sara Golemon
999c6f2c5d
Bump for 8.0.15 2021-12-02 05:09:07 +00:00
Christoph M. Becker
816aa20391
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74604: Out of bounds in php_pcre_replace_impl
2021-11-29 19:15:20 +01:00
Christoph M. Becker
712fc54e85
Fix #74604: Out of bounds in php_pcre_replace_impl
Trying to allocate a `zend_string` with a length only slighty smaller
than `SIZE_MAX` causes an integer overflow; we make sure that this
doesn't happen by catering to the maximal overhead of a `zend_string`.

Closes GH-7597.
2021-11-29 19:12:55 +01:00
Christoph M. Becker
f3bd24a200
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81659: stream_get_contents() may unnecessarily overallocate
2021-11-29 14:48:11 +01:00
Christoph M. Becker
31749aac62
Fix #81659: stream_get_contents() may unnecessarily overallocate
Since we're going to read from the current stream position anyway, the
`max_len` should be the size of the file minus the current position
(still catering to potentially filtered streams).  We must, however,
make sure to cater to the file position being beyond the actual file
size.

While we're at, we also fix the step size in the comment, which is 8K.

A further optimization could be done for unfiltered streams, thus
saving that step size, but 8K might not be worth it.

Closes GH-7693.
2021-11-29 14:46:09 +01:00
Christoph M. Becker
179030d167
Fix #81649: imap_(un)delete accept sequences, not single numbers
As such, the parameter name `$message_num` is utmost misleading; it
should be `$message_nums` as for other functions.

Closes GH-7686.
2021-11-25 18:29:43 +01:00
Nikita Popov
be271f277e Fix bug #81652
We need to check not only for defs but also for uses of the
variable.
2021-11-24 15:18:31 +01:00
Christoph M. Becker
b29e85a0da
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #75725: ./configure: detecting RAND_egd
2021-11-22 14:13:52 +01:00
Дилян Палаузов
60fe575ce3
Fix #75725: ./configure: detecting RAND_egd
Closes GH-7668.
2021-11-22 14:11:07 +01:00
Nikita Popov
4d4fe7639f Fixed bug #81631
We need to save the opline before fetching the operand, as it may
throw an undef var warning.
2021-11-17 16:06:25 +01:00
Christoph M. Becker
b963208640
[ci skip] Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  [ci skip] Fix news entry for bug #79971
  [ci skip] Update NEWS
2021-11-16 13:13:54 +01:00
Christoph M. Becker
8a2076475e
[ci skip] Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  [ci skip] Fix news entry for bug #79971
  [ci skip] Update NEWS
2021-11-16 13:11:53 +01:00
Christoph M. Becker
d14a9139d5
[ci skip] Fix news entry for bug #79971 2021-11-16 13:06:04 +01:00
Nikita Popov
9e25c4b3a6 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81626
2021-11-16 12:46:20 +01:00
Nikita Popov
d26965b247 Fixed bug #81626
Backport of a8926474cb to 7.4.
2021-11-16 12:45:33 +01:00