Commit Graph

6170 Commits

Author SHA1 Message Date
Michael Voříšek
d313ad6098
Deprecate E_STRICT constant and remove error level
RFC: https://wiki.php.net/rfc/deprecations_php_8_4#remove_e_strict_error_level_and_deprecate_e_strict_constant

Closes GH-13053
2024-09-18 14:33:14 +02:00
Niels Dossche
31e2ec63d8
Fix GH-15923: GDB: Python Exception <class 'TypeError'>: exceptions must derive from BaseException
Triggers on release builds when printing data structures.
You can't raise a string, you must raise exceptions.

Closes GH-15928.
2024-09-17 19:24:18 +02:00
Peter Kokot
888eb370cf
Fix -Wundef/C4668 warnings (#15853)
- ZTS is either undefined or defined (to 1)
- PHP_WIN32 is either undefined or defined (to 1)
- HAVE_LIBEDIT is either undefined or defined (to 1)
2024-09-14 11:28:32 +02:00
Christoph M. Becker
edcd6cc564
gai_strerror() is not thread-safe on Windows (GH-15568)
First we refactor to have only a single usage of `PHP_GAI_STRERROR()`
left; then we drop the macro in favor of calling the different
functions conditionally in an ad-hoc style.

This is necessary because the return value of `php_win32_error_to_msg`
needs to be freed by the caller.

The error messages are no more inline with other error messages, since
`gai_strerror()` apparently always appends a period and a space.

We also properly configure IPv4/v6 on Windows.  Since WSPiApi.h has been
created in 2000, so we can safely assume that it is available everywhere
nowadays.  Furthermore, `gai_strerror()` is available regardless of
whether there is IPv6 support.
2024-09-08 16:16:40 +02:00
Christoph M. Becker
50b3a0d011
Add comments about internal headers (GH-15689)
A common convention is to name internal C header files as `*_int.h`.
Since a couple of these are actually installed, we add comments that
this is not supposed to happen, (a) to avoid installing further
internal headers, and (b) to pave the way to fix this in the next major
PHP version.

Somewhat special is php_gmp_int.h, where "int" is meant as abbreviation
for "interface".

Another common convention is appending `_priv` or `_private`, but since
there have not been any issues regarding these headers so far, we
refrain from adding respective comments to these headers.

Anyhow, it might be a good idea to introduce some common naming
convention for such internal/private headers.
2024-09-08 16:11:25 +02:00
Bob Weinand
25d761623c
Make internal run_time_cache a persistent allocation (#15040)
We also add zend_map_ptr_static, so that we do not incur the overhead of constantly recreating the internal run_time_cache pointers on each request.
This mechanism might be extended for mutable_data of internal classes too.
2024-09-07 01:45:26 +02:00
Niels Dossche
0d616d1b82
Fix GH-15693: Unnecessary include in main.c bloats binary
Closes GH-15700.
2024-09-02 21:54:13 +02:00
Christoph M. Becker
55f519b178
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15628: php_stream_memory_get_buffer() not zero-terminated
2024-09-01 14:58:14 +02:00
Christoph M. Becker
5f504f10dd
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15628: php_stream_memory_get_buffer() not zero-terminated
2024-09-01 14:56:54 +02:00
Christoph M. Becker
93021c635d
Fix GH-15628: php_stream_memory_get_buffer() not zero-terminated
We're reasonably sure that appending the NUL is not an OOB write, since
the memory stream implementation uses `zend_string` APIs instead of
fiddling with the buffer.

We don't add a regression test because that would require to set up
something in the zend_test extension, and regressions are supposed
to be caught by external consumers of this API, such as mailparse.

Closes GH-15648.
2024-09-01 14:55:40 +02:00
Niels Dossche
a092bcb4d7
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15565: --disable-ipv6 during compilation produces error EAI_SYSTEM not found
2024-08-24 14:16:40 +02:00
Niels Dossche
8da94cfc41
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15565: --disable-ipv6 during compilation produces error EAI_SYSTEM not found
2024-08-24 14:14:57 +02:00
Niels Dossche
4b6575a1f9
Fix GH-15565: --disable-ipv6 during compilation produces error EAI_SYSTEM not found
Closes GH-15567.
2024-08-24 14:14:20 +02:00
Jakub Zelenka
70c5e366f6
Revert fix for GH-14930: truncating readdir output (#15533) 2024-08-22 23:41:34 +01:00
Gina Peter Banyard
35fbb0061d
main/network: Use more appropriate types (#15511)
* main/network: Use more appropriate types

And check directly against 0 for success for functions not returning a zend_result

* Remove redundant declaration in file.h

Not sure why it even is here
2024-08-22 12:48:28 +01:00
Gina Peter Bnayard
5853cdb73d Use "must not" instead of "cannot" wording 2024-08-21 21:12:17 +01:00
Jakub Zelenka
0b61b8dc99
PHP-8.3 is now for PHP-8.3.12-dev 2024-08-13 20:16:40 +01:00
Sergey Panteleev
84d8fa9f53
PHP-8.2 is now for PHP 8.2.24-dev 2024-08-13 17:18:16 +03:00
Calvin Buckley
afc5738154
Show build provider and unify version information printing (#14657)
* Show build provider information in "php -v"

Vendors such as distributions can set the `PHP_BUILD_PROVIDER`
variable, that gets printed in phpinfo. However, I find that users check
`php -v` more often than phpinfo to see what PHP they're running. The
problem with this is that it does not show that build provider
information.

This change makes the build provider information printed on an
additional line of the version information.

* Put on same line so it works with or without env var

Unbreaks build without PHP_BUILD_PROVIDER set.

* change wording in provider version text

better grammatically; many different possibilities here though

* Unify SAPI version printing

This makes it so that all of the SAPIs share the same code for printing
version information. This is useful in case of any future changes to the
version information, such as i.e. adding build provider to the output.

* Make include for php_print_version explicit

* Preserve phpdbg version and output channel

php_printf doesn't have same semantics, as phpdbg_out could be on a
different output than stdout/err. Also add the phpdbg version (in case
it differs from PHP's, to keep similar output before this PR)

* remove size variables

we don't use them and CI doesn't like unused variables

* Fix format string insecurity
2024-08-12 23:24:41 -03:00
Gina Peter Banyard
fd570fbfe8
main/streams: Voidify statbuf_from_array() (#15319)
It always returned SUCCESS
2024-08-10 00:59:37 +01:00
Christoph M. Becker
887e6b9c45
Fix GH-15181: Disabled output handler is flushed again
When an `PHP_OUTPUT_HANDLER_FAILURE` occurs, the output handler becomes
disabled (i.e. the `PHP_OUTPUT_HANDLER_DISABLED` flag is set).  However,
there is no guard for disabled handlers in `php_output_handler_op()`
what may cause serious issues (as reported, UB due to passing `NULL` as
the 2nd argument of `memcpy`, because the handler's buffer has already
been `NULL`ed).  Therefore, we add a respective guard for disabled
handlers, and return `PHP_OUTPUT_HANDLER_FAILURE` right away.

Closes GH-15183.
2024-08-06 16:45:51 +02:00
Peter Kokot
95447e03fb
[skip ci] Remove obsolete comment (#15225)
HAVE_ODBC is ambiguous what this does and neither the macro is used in
the current code base anymore.
2024-08-05 07:47:59 +02:00
Niels Dossche
32fe9bc430
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix uninitialized memory in network.c
2024-07-22 22:26:02 +02:00
Niels Dossche
40e0e92212
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix uninitialized memory in network.c
2024-07-22 22:25:53 +02:00
Niels Dossche
40551dd74b
Fix uninitialized memory in network.c
See https://github.com/php/php-src/issues/14806#issuecomment-2208150509
and https://github.com/php/php-src/issues/14806#issuecomment-2208690481

Closes GH-15068.
2024-07-22 22:25:28 +02:00
Niels Dossche
d75abdcec4
Add assertion to error path in streams.c (#15027)
This makes the developer intent clear and should prevent some false
reports.
2024-07-19 14:51:54 +02:00
David CARLIER
2aeff2c988
main: update Winsock api version to 2.2 (#14909)
not been updated since php 4 whereas 2.2 is available even in Win2000.
2024-07-17 14:17:29 +01:00
Pierrick Charron
e07813ad46
PHP-8.2 is now for PHP 8.2.23-dev 2024-07-16 12:20:55 -04:00
Eric Mann
155e89e12f
PHP-8.3 is now for PHP 8.3.11-dev 2024-07-16 06:45:20 -07:00
Niels Dossche
3703459c3e
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-14930: Custom stream wrapper dir_readdir output truncated to 255 characters in PHP 8.3
2024-07-12 19:28:37 +02:00
Joe Cai
38501ed48a
Fix GH-14930: Custom stream wrapper dir_readdir output truncated to 255 characters in PHP 8.3
Revert "Reserve less file space if possible in a directory entry"
This reverts commit 00c1e7bf0f.

Closes GH-14933.
2024-07-12 19:26:42 +02:00
Peter Kokot
2ebef11e83
Update http links to https and sync www.php.net URLs (#14854) 2024-07-07 04:23:08 +02:00
Andy Postnikov
1f64e7c253
Fix build for armv7 (#14801) 2024-07-06 15:21:45 +02:00
Niels Dossche
279d82bb07
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-14808: Unexpected null pointer in Zend/zend_string.h with empty output buffer
2024-07-04 15:50:44 +02:00
Niels Dossche
519c435fc6
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-14808: Unexpected null pointer in Zend/zend_string.h with empty output buffer
2024-07-04 15:50:32 +02:00
Niels Dossche
89c3e0346a
Fix GH-14808: Unexpected null pointer in Zend/zend_string.h with empty output buffer
The output buffer can be NULL when the number of bytes is zero.

Closes GH-14815.
2024-07-04 15:49:58 +02:00
Arnaud Le Blanc
11accb5cdf
Preferably include from build dir (#13516)
* Include from build dir first

This fixes out of tree builds by ensuring that configure artifacts are included
from the build dir.

Before, out of tree builds would preferably include files from the src dir, as
the include path was defined as follows (ignoring includes from ext/ and sapi/) :

    -I$(top_builddir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/main
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM
    -I$(top_builddir)/

As a result, an out of tree build would include configure artifacts such as
`main/php_config.h` from the src dir.

After this change, the include path is defined as follows:

    -I$(top_builddir)/main
    -I$(top_builddir)
    -I$(top_srcdir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM

* Fix extension include path for out of tree builds

* Include config.h with the brackets form

`#include "config.h"` searches in the directory containing the including-file
before any other include path. This can include the wrong config.h when building
out of tree and a config.h exists in the source tree.

Using `#include <config.h>` uses exclusively the include path, and gives
priority to the build dir.
2024-06-26 00:26:43 +02:00
Arnaud Le Blanc
ff58a7f624
Merge branch 'PHP-8.3'
* PHP-8.3:
  [ci skip] NEWS for GH-13922
  [ci skip] NEWS for GH-13922
  Support sysconf(_SC_GETPW_R_SIZE_MAX) == -1 (#13922)
2024-06-24 19:57:28 +02:00
Arnaud Le Blanc
b1119de0c9
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [ci skip] NEWS for GH-13922
  Support sysconf(_SC_GETPW_R_SIZE_MAX) == -1 (#13922)
2024-06-24 19:56:19 +02:00
Arnaud Le Blanc
3fbca7fb6a
Support sysconf(_SC_GETPW_R_SIZE_MAX) == -1 (#13922) 2024-06-24 19:52:55 +02:00
Jakub Zelenka
387b1c62bf
PHP-8.3 is now for PHP-8.3.10-dev 2024-06-19 00:05:24 +01:00
Sergey Panteleev
49aaa7cd9f
PHP-8.2 is now for PHP 8.2.22-dev 2024-06-18 17:56:05 +03:00
Bob Weinand
6a2c5318f9
Optimize observers (#13649)
Inline the lookup whether a function is observed at all.
This strategy is also used for FRAMELESS calls. If the frameless call is observed, we instead allocate a call frame and push the arguments, to call the the function afterwards.
Doing so is still a performance benefit as opposed to executing individual INIT_FCALL+SEND_VAL ops. Thus, even if the frameless call turns out to be observed, the call overhead is slightly lower than before.
If the internal function is not observed at all, the unavoidable overhead is fetching the FLF zend_function pointer and the run-time cache needs to be inspected.

As part of this work, it turned out to be most viable to put the result operand on the ZEND_OP_DATA instead of ZEND_FRAMELESS_ICALL_3, allowing seamless interoperability with the DO_ICALL opcode.
This is a bit unusual in comparison to all other ZEND_OP_DATA usages, but seems to not pose problems overall.

There is also a small issue resolved: trampolines would always use the ZEND_CALL_TRAMPOLINE_SPEC_OBSERVER function due to zend_observer_fcall_op_array_extension being set to -1 too late.
2024-06-15 14:42:27 +02:00
Derick Rethans
4b24f5d6db
Merge branch 'PHP-8.3' 2024-06-13 14:04:48 +01:00
Derick Rethans
31798e4b6d
Merge branch 'PHP-8.2' into PHP-8.3 2024-06-13 14:04:13 +01:00
Derick Rethans
ad56ec7bbf
Fixed off-by-one error in checking length of abtract namespace Unix sockets 2024-06-13 12:46:22 +01:00
Arnaud Le Blanc
d1048a0869
Add zend_random_bytes(), zend_random_bytes_insecure() functions (#14054)
Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
2024-06-12 17:27:01 +02:00
Peter Kokot
5d3fab9334
Sync #if/ifdef/defined (#14520)
These are either undefined or defined (to value 1):
- __DragonFly__
- __FreeBSD__
- HAS_MCAST_EXT
- HAVE_GETCWD
- HAVE_GETWD
- HAVE_GLIBC_ICONV
- HAVE_JIT
- HAVE_LCHOWN
- HAVE_NL_LANGINFO
- HAVE_RL_CALLBACK_READ_CHAR
- HAVE_RL_ON_NEW_LINE
- HAVE_SQL_EXTENDED_FETCH
- HAVE_UTIME

Follow up of GH-5526 (-Wundef)
2024-06-11 22:47:05 +02:00
Ilija Tovilo
da7bc2ea04
Merge branch 'PHP-8.3'
* PHP-8.3:
  Set SG(rfc1867_uploaded_files) to null after destroy
2024-06-10 23:03:49 +02:00
Ilija Tovilo
ad470a974d
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Set SG(rfc1867_uploaded_files) to null after destroy
2024-06-10 23:03:37 +02:00