Commit graph

761 commits

Author SHA1 Message Date
Jakub Zelenka
6976fb6ba7
Merge branch 'PHP-8.3' into PHP-8.4 2025-03-11 22:23:09 +01:00
Jakub Zelenka
acf2f4988a
Merge branch 'PHP-8.2' into PHP-8.3 2025-03-11 22:09:00 +01:00
Jakub Zelenka
4af1830356
Merge branch 'PHP-8.1' into PHP-8.2 2025-03-11 21:57:33 +01:00
Niels Dossche
0e715e71d9
Fix GHSA-wg4p-4hqh-c3g9 2025-03-11 21:50:17 +01:00
Niels Dossche
575ee23bd9
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17187: unreachable program point in zend_hash
2024-12-27 15:54:37 +01:00
Niels Dossche
b621b3a00f
Fix GH-17187: unreachable program point in zend_hash
A bunch of different issues:
1) The referenced value is copied without incrementing the refcount.
   The reason the refcount isn't incremented is because otherwise
   the array modifications would violate the RC1 constraints.
   Solve this by copying the reference itself instead and always
   read the referenced value.
2) No type checks on the array data, so malicious scripts could
   cause type confusion bugs.
3) Potential overflow when the arrays resize and we access ctag.

Closes GH-17205.
2024-12-27 15:51:17 +01:00
Niels Dossche
14c107371c Backport 061058a9: Test fixes for libxml2 2.12.0 2024-10-12 15:12:40 +02:00
Niels Dossche
bb46b4b799 Backport 4fe82131: Backport libxml2 2.13.2 fixes (#14816)
Backproted from https://github.com/php/php-src/pull/14789
2024-10-12 15:12:40 +02:00
Niels Dossche
e7b022ea17
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15868: Assertion failure in xml_parse_into_struct after exception
  Fix GH-15868: Assertion failure in xml_parse_into_struct after exception
2024-09-13 20:02:00 +02:00
Niels Dossche
6c82ca2182
Fix GH-15868: Assertion failure in xml_parse_into_struct after exception
Upon unwinding from an exception, the parser state is not stable, we
should not continue updating the values if an exception was thrown.

Closes GH-15879.
2024-09-13 20:01:44 +02:00
Niels Dossche
ac8db36543
Fix GH-15868: Assertion failure in xml_parse_into_struct after exception
Upon unwinding from an exception, the parser state is not stable, we
should not continue updating the values if an exception was thrown.

Closes GH-15879.
2024-09-13 19:59:41 +02:00
DanielEScherzer
db545767e5
Rename ZEND_STR_DEPRECATED to ZEND_STR_DEPRECATED_CAPITALIZED (#15831)
To match other capitalized strings like `ZEND_STR_UNKNOWN_CAPITALIZED` and
`ZEND_STR_ARRAY_CAPITALIZED`. Since this known string was only added in PHP
8.4, no backwards compatibility alias is needed.
2024-09-10 22:45:23 +01:00
DanielEScherzer
53cb89670c
Generated arginfo header files: remove empty zend_function_entry arrays (#15705)
When a class (or enum) has no methods, rather than using an array that only
contains `ZEND_FE_END`, use `NULL` for the functions. The implementation of
class registration for internal classes, `do_register_internal_class()` in
zend_API.c, already skips classes where the functions are `NULL`. By removing
these unneeded arrays, we can reduce the size of the header files, while also
removing an unneeded call to zend_register_functions() for each internal class
with no extra methods.
2024-09-03 23:19:53 +02:00
Máté Kocsis
8d12f666ae
Fix registration of internal readonly child classes (#15459)
Currently, internal classes are registered with the following code:

INIT_CLASS_ENTRY(ce, "InternalClass", class_InternalClass_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ...;

This has worked well so far, except if InternalClass is readonly. It is because some inheritance checks are run by zend_register_internal_class_ex before ZEND_ACC_READONLY_CLASS is added to ce_flags.

The issue is fixed by adding a zend_register_internal_class_with_flags() zend API function that stubs can use from now on. This function makes sure to add the flags before running any checks. Since the new API is not available in lower PHP versions, gen_stub.php has to keep support for the existing API for PHP 8.3 and below.
2024-08-24 12:36:54 +02:00
Gina Peter Bnayard
caae950ff7 ext/xml: Add an explicit test case about unsetting a handler with empty string 2024-08-11 15:00:27 +02:00
Gina Peter Banyard
25b4696530
ext/xml: Deprecate xml_set_object() and passing non-callable strings as handlers (#15293) 2024-08-08 23:37:49 +01:00
Peter Kokot
f66feaec0f
Sync HAVE_<extension> help texts (#15167)
This syncs all help texts of extension preprocessor macros to the same
style "Define to 1 if the PHP extension '<ext>' is available.".
[skip ci]
2024-08-02 01:41:47 +02:00
Peter Kokot
8356dadb59
Autotools: Fix xml extension dependency (#15162)
The PHP_ADD_EXTENSION_DEP Autoconf macro needs to be called after
PHP_NEW_EXTENSION to be fully effective. This simplifies the code and
checks. Also, due to the current order_by_dep.awk script implementation
it needs to be on its own line with arguments unquoted so that awk can
parse the config.m4 file. Until order_by_dep.awk script is fixed.
2024-07-30 09:17:11 +02:00
Peter Kokot
32210ce967
Autotools: Sync CS in XML related extensions (#15110)
- PHP_SETUP_LIBXML arguments quoted
- Help texts updated for HAVE_LIBXML, HAVE_DOM, HAVE_XMLREADER,
  HAVE_XMLWRITER, HAVE_SOAP, HAVE_SIMPLEXML, and HAVE_XML CPP macros
- Duplicate HAVE_LIBXML symbol definition in PHP_SETUP_LIBXML M4 macro
  removed (the HAVE_LIBXML marks that PHP libxml extension is available and
  not only that libxml2 library is available)
2024-07-27 22:48:51 +02:00
Niels Dossche
776939c3db Avoid function pointer cast to preserve ability to do CFI 2024-07-06 13:49:45 -07:00
Niels Dossche
ff3e7679b1 Avoid pointless cast to prevent implementation-defined conversion warning 2024-07-06 13:49:45 -07:00
Niels Dossche
292e936ca8 Handle invalid values better in PHP_XML_OPTION_SKIP_TAGSTART 2024-07-06 13:49:45 -07:00
Niels Dossche
19358d638b Stop using reserved names 2024-07-06 13:49:45 -07:00
Niels Dossche
335d6f023f Fix grammar mistake in comment in xml.c 2024-07-06 13:49:45 -07:00
Niels Dossche
be2d9fd80e Remove unused include from xml.c 2024-07-06 13:49:45 -07:00
Niels Dossche
ec1998987b Remove pointless const specifier on scalar argument 2024-07-06 13:49:45 -07:00
Niels Dossche
2ab24b0a94 Remove unused arguments from _external_entity_ref_handler() 2024-07-06 13:49:45 -07:00
Niels Dossche
b41e90c6f9
Fix bug #81481 (xml_get_current_byte_index limited to 32-bit numbers on 64-bit builds) (#14845)
The return value is long in both expat and expat2 (with XML_LARGE_SIZE
not set).
2024-07-06 18:34:17 +02:00
Niels Dossche
b418d19c42
[ci skip] Make test more robust 2024-07-06 14:46:07 +02:00
Niels Dossche
fff206ba1e
Merge branch 'PHP-8.3'
* PHP-8.3:
  [ci skip] Test is for libxml only
2024-07-06 14:42:05 +02:00
Niels Dossche
459d79db95
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [ci skip] Test is for libxml only
2024-07-06 14:41:56 +02:00
Niels Dossche
0b6289dab8
[ci skip] Test is for libxml only 2024-07-06 14:41:44 +02:00
Niels Dossche
f98aa06c68
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-14834: Error installing PHP when --with-pear is used
2024-07-06 13:52:42 +02:00
Niels Dossche
9a337a85bf
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-14834: Error installing PHP when --with-pear is used
2024-07-06 13:52:34 +02:00
Niels Dossche
67259e451d
Fix GH-14834: Error installing PHP when --with-pear is used
libxml2 2.13 makes changes to how the parsing state is set, update our
code accordingly. In particular, it started reporting entities within
attributes, while it should only report entities inside text nodes.

Closes GH-14837.
2024-07-06 13:52:02 +02:00
Niels Dossche
b4384488bc
Merge branch 'PHP-8.3'
* PHP-8.3:
  NEWS for compatibility in XML
  Stop setting parse options directly
  Stop relying on lastError directly
  Stop relying on the sax2 flag directly
  Port XML_GetCurrentByteIndex to public APIs
2024-07-06 13:50:32 +02:00
Niels Dossche
a1bcaf05b0
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  NEWS for compatibility in XML
  Stop setting parse options directly
  Stop relying on lastError directly
  Stop relying on the sax2 flag directly
  Port XML_GetCurrentByteIndex to public APIs
2024-07-06 13:50:23 +02:00
Niels Dossche
e5e15fd229
Stop setting parse options directly
Setting this directly will be deprecated in libxml2 2.14.
2024-07-06 13:46:16 +02:00
Niels Dossche
823d0588f7
Stop relying on lastError directly
Reading this directly will become deprecated in libxml2 2.14.
2024-07-06 13:46:15 +02:00
Niels Dossche
6490a18271
Stop relying on the sax2 flag directly
Setting this directly will become deprecated in libxml2 2.14.
2024-07-06 13:46:15 +02:00
Niels Dossche
8dc799aac7
Port XML_GetCurrentByteIndex to public APIs
This is necessary to avoid a deprecation break in libxml2 2.14.x.
2024-07-06 13:46:15 +02:00
Niels Dossche
8c8322f6a1
ext/xml: Use zend_hash_find_ptr_lc() to avoid allocation in some cases (#14840) 2024-07-06 13:44:10 +02:00
Niels Dossche
ecf0bb0fd1
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [ci skip] NEWS
  Backport libxml2 2.13.2 fixes (#14816)
2024-07-04 15:37:35 +02:00
Niels Dossche
4fe821311c
Backport libxml2 2.13.2 fixes (#14816)
Backproted from https://github.com/php/php-src/pull/14789
2024-07-04 15:29:50 +02:00
Niels Dossche
87599717c9 Avoid pointless duplication in _end_element_handler 2024-07-04 02:21:59 -07:00
Niels Dossche
81cdb8caf2 Remove unused code from xml/compat.c 2024-07-04 02:21:59 -07:00
Niels Dossche
85705eda71 Fix compilation on libxml2 2.13 2024-07-03 10:34:46 -07:00
Peter Kokot
bee84c0468
Autotools: Quote PHP_SUBST arguments in extensions (#14748) 2024-07-02 06:56:18 +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
David CARLIER
8eb0889d90
Fix GH-14637: memory leak after failed heap allocation due to mem limit. (#14641) 2024-06-23 21:43:02 +01:00