Commit graph

1705 commits

Author SHA1 Message Date
Florian Engelhardt
29b38a1ced
Fix GH-19226: Segfault when spawning new thread in soap extension
Closes GH-19228.
2025-07-24 11:56:43 +02:00
DanielEScherzer
1eadf553f1
Arginfo: avoid using temporary zvals for initializing attribute values (#19141)
Instead of
* adding a zval on the stack
* initializing it
* copying the value to the attribute

Just initialize the value directly in the zend_attribute_arg
2025-07-21 13:33:51 -07:00
Niels Dossche
d7f9caf37c
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-18640: heap-use-after-free ext/soap/php_encoding.c:299:32 in soap_check_zval_ref
2025-07-20 19:50:01 +02:00
Niels Dossche
f8196a5db5
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-18640: heap-use-after-free ext/soap/php_encoding.c:299:32 in soap_check_zval_ref
2025-07-20 19:49:56 +02:00
Niels Dossche
6cc4ae1f1d
Fix GH-18640: heap-use-after-free ext/soap/php_encoding.c:299:32 in soap_check_zval_ref
For attributes, relying on the ref_map doesn't make sense the first
place as you can't really refer to attributes from attributes.
The code therefore assumes that the node is unique, which is broken.

Closes GH-19181.
2025-07-20 19:49:22 +02:00
Niels Dossche
03a9f03822
Migrate from xmlNewNode to xmlNewDocNode (#19182)
The former is discouraged [1].

[1] https://gnome.pages.gitlab.gnome.org/libxml2/html/tree_8h.html#aa39c05fb472571ed00e38c065e67d2ec
2025-07-19 23:29:04 +02:00
Daniel Scherzer
142e378618 Arginfo: add and use known strings for attribute values 2025-07-14 17:31:22 -07:00
Niels Dossche
f6380e4a38
Merge branch 'PHP-8.4'
* PHP-8.4:
  ext/soap/php_http.c: Fix memory leak of header value
2025-07-10 22:32:58 +02:00
Niels Dossche
de7a212630
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  ext/soap/php_http.c: Fix memory leak of header value
2025-07-10 22:32:52 +02:00
Gina Peter Banyard
85a49d4198
ext/soap/php_http.c: Fix memory leak of header value 2025-07-10 22:32:31 +02:00
DanielEScherzer
9225cb45ac
Make zend_register_*_constant() functions return pointers, use them (#19029)
Have each of the specialized methods for registering a constant return a
pointer to the registered constant the same way that the generic
`zend_register_constant()` function does, and use those in the generated
arginfo files to avoid needing to search for a constant that was just
registered in order to add attributes to it.
2025-07-07 12:23:52 -07:00
Niels Dossche
aa0e8bf568 Use ZVAL_NULL() directly for Z_CLIENT_USE_PROXY_P()
This is just a `?int` property, no need to do anything fancy.
2025-07-03 20:37:10 +02:00
Niels Dossche
8fdd434bb5 Don't deref soap private properties
They are private and can't be made references.
2025-07-03 20:37:10 +02:00
Niels Dossche
e6e0887005 soap: Avoid redundant copying of http body string 2025-07-03 20:28:38 +02:00
Niels Dossche
32f0d24e1f soap: Get decompression function directly from function table and call it
The code is already looking up the entry in the function table anyway,
so might as well use it directly.
This simplifies the code and avoids a redundant lookup.
2025-07-03 20:28:38 +02:00
Niels Dossche
51149b65ad
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-18990, bug #81029, bug #47314: SOAP HTTP socket not closing on object destruction
  Fix leak when path is too long in ZipArchive::extractTo()
  curl: Remove incorrect string release on error
2025-07-02 18:47:53 +02:00
Niels Dossche
764154dc75
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-18990, bug #81029, bug #47314: SOAP HTTP socket not closing on object destruction
  Fix leak when path is too long in ZipArchive::extractTo()
  curl: Remove incorrect string release on error
2025-07-02 18:46:37 +02:00
Niels Dossche
69328ba304
Fix GH-18990, bug #81029, bug #47314: SOAP HTTP socket not closing on object destruction
Currently the resource is attached to the object and its refcount is
increased. This means that the refcount to the resource is 2 instead of
1 as expected. A refcount of 2 is necessary in the current code because
of how the error handling works: by using convert_to_null() the resource
actually goes to rc_dtor_func(), dropping its refcount to 1. So on error
the refcount is correct.
To solve the issue, let `stream` conceptually be a borrow of the
resource with refcount 1, and just use ZVAL_NULL() to prevent calling
rc_dtor_func() on the resource.

Closes GH-19001.
2025-07-02 18:44:05 +02:00
Ahmed Lekssays
dd060656d3
Fix GHSA-453j-q27h-5p8x
Libxml versions prior to 2.13 cannot correctly handle a call to
xmlNodeSetName() with a name longer than 2G. It will leave the node
object in an invalid state with a NULL name. This later causes a NULL
pointer dereference when using the name during message serialization.

To solve this, implement a workaround that resets the name to the
sentinel name if this situation arises.

Versions of libxml of 2.13 and higher are not affected.

This can be exploited if a SoapVar is created with a fully qualified
name that is longer than 2G. This would be possible if some application
code uses a namespace prefix from an untrusted source like from a remote
SOAP service.

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-07-01 09:35:03 -07:00
Ilija Tovilo
49d94cced0
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GHSA-453j-q27h-5p8x
  Fix GHSA-hrwm-9436-5mv3: pgsql escaping no error checks
  Fix GHSA-3cr5-j632-f35r: Null byte in hostnames
2025-07-01 17:48:00 +02:00
Ahmed Lekssays
a179e39c38
Fix GHSA-453j-q27h-5p8x
Libxml versions prior to 2.13 cannot correctly handle a call to
xmlNodeSetName() with a name longer than 2G. It will leave the node
object in an invalid state with a NULL name. This later causes a NULL
pointer dereference when using the name during message serialization.

To solve this, implement a workaround that resets the name to the
sentinel name if this situation arises.

Versions of libxml of 2.13 and higher are not affected.

This can be exploited if a SoapVar is created with a fully qualified
name that is longer than 2G. This would be possible if some application
code uses a namespace prefix from an untrusted source like from a remote
SOAP service.

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-07-01 23:01:17 +09:00
DanielEScherzer
171501b93f
Replace @deprecated with #[\Deprecated] for internal constants (#18780)
Only covers constants declared via stub files, others will be handled
separately in a later commit.

Does not include the intl extension, since that had some errors relating to the
cpp code; that extension will be updated separately.
2025-06-26 11:27:15 -07:00
Gina Peter Banyard
091308cb3e ext/soap: Remove bool type coercions in tests 2025-06-21 22:19:03 +02:00
Niels Dossche
9859d837ca
Implement request #61105: Support Soap 1.2 SoapFault Reason Text lang attribute
This is on the border line of a bugfix and a new feature.
Anyway, this is necessary to fix compatibility with .NET clients.

Closes GH-18701.
2025-06-21 00:18:08 +02:00
Niels Dossche
f46f42b2b2
Implement request #55503: Extend __getTypes to support enumerations (#18704)
Co-authored-by: datibbaw <datibbaw@php.net>
2025-06-04 17:46:57 +02:00
Niels Dossche
3cb7d1bd8a
Remove custom UTF-8 check function from ext/libxml
This was originally introduced as a workaround for a libxml2 bug [1].
This bug has been fixed for more than a decade [2], and we can use the
libxml2 API again. We bumped our version requirement for libxml2 beyond
that in 7.4 [3].

[1] 7e53511ec8
[2] 3ffe90ea1c
[3] 74235ca5f3

Closes GH-18706.
2025-05-30 10:40:23 +02:00
Niels Dossche
56abb316eb
Fix bug #70951: Segmentation fault on invalid WSDL cache
We mix in the endianness and the zend_long size to make sure cache files
can't be used on incompatible architectures.

Closes GH-18707.
2025-05-30 00:04:06 +02:00
Niels Dossche
615b9803bb
Get rid of redundant SOAP globals (#18702)
The copy doesn't make sense, remove it.
2025-05-29 20:14:57 +02:00
Niels Dossche
c267caa542
Deduplicate XML parsing code for SOAP (#18700)
* Deduplicate XML parsing code for SOAP

* Apply suggestions from code review

Co-authored-by: Gina Peter Banyard <girgias@php.net>

---------

Co-authored-by: Gina Peter Banyard <girgias@php.net>
2025-05-29 18:35:19 +02:00
Niels Dossche
bd47c14c50
Also allow XSD_1999_NAMESPACE 2025-05-29 18:26:46 +02:00
Niels Dossche
c44196143a
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix potential NULL deref
2025-05-29 16:57:47 +02:00
Niels Dossche
dd856d5ad9
Fix potential NULL deref
Backported from GH-18697.
2025-05-29 16:57:32 +02:00
Niels Dossche
6399012cee
Fix namespace handling of WSDL and XML schema in SOAP
`attr_is_equal_ex` makes no sense: attributes never inherit the
namespace of their element. Yet this is wrongly used as a combo for
checking both the node namespace and attribute namespace.
Furthermore, not all nodes have the proper namespace check.
Fix all of this by reworking the helpers and auditing the calls to the
namespace helpers.

Closes GH-16320.
Closes bug #68576.
Closes GH-18697.
2025-05-29 16:55:41 +02:00
Gina Peter Banyard
c9e571560f
ext/soap: Refactor to_zval_bool() (#18696)
- Early return style
- Improve logic to get rid of unnecessary comparisons
- Do not use convert_to_boolean API
2025-05-29 15:29:55 +01:00
Gina Peter Banyard
407c9781f9
ext/soap: Replace single usage of CHECK_XML_NULL with FIND_XML_NULL (#18698)
This removes the implicit assumption about the variable name of the zval
Moreover, nearby the FIND_XML_NULL macro is used anyway.
2025-05-29 15:07:35 +01:00
Niels Dossche
8b4edf0229 Remove unused function in soap 2025-05-29 10:02:43 +02:00
Niels Dossche
21691cb19b Remove uncommented init/cleanup code
This is irrelevant and is done by ext/libxml.
2025-05-29 10:02:43 +02:00
Niels Dossche
564df33ac1 Add FIXME 2025-05-29 10:02:43 +02:00
Niels Dossche
6723e88798 Add const qualifiers for php_xml 2025-05-29 10:02:43 +02:00
Niels Dossche
ba80d0be99 Fix indentation 2025-05-29 10:02:43 +02:00
Niels Dossche
9e01337a21 Remove unused soap macros 2025-05-29 10:02:43 +02:00
Niels Dossche
b05d50eac2 Avoid creating a zend_string twice in soap do_request 2025-05-28 21:04:06 +02:00
Niels Dossche
99bc0a56a6 Use function table directly in soap do_request
The function will exist, avoid creating a temporary string and
lowercasing it.
2025-05-28 21:04:06 +02:00
Niels Dossche
b156d37d7f
Use zend_array_is_list() in soap instead of own is_map() (#18684)
is_map() is just the inverse of zend_array_is_list().
2025-05-28 20:12:54 +02:00
David CARLIER
7e956f879e
ext/soap: SoapServer::handle() reduce retval scope. (#18657)
might have been a relic of past modifications,
but pushing it down to the actual first case of error path.
2025-05-25 22:15:31 +01:00
Niels Dossche
ac3eb678aa
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leaks in php_http.c when call_user_function() fails
2025-05-24 21:54:50 +02:00
Niels Dossche
83755748fd
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leaks in php_http.c when call_user_function() fails
2025-05-24 21:54:45 +02:00
Niels Dossche
a44e3f442f
Fix memory leaks in php_http.c when call_user_function() fails
retval can be refcounted but is not destroyed.

Closes GH-18638.
2025-05-24 21:54:19 +02:00
Remi Collet
b17df7a07c
Merge branch 'PHP-8.4'
* PHP-8.4:
  NEWS for #66049
  NEWS for #66049
  Fix #66049 Typemap can break parsing in parse_packet_soap leading to a segfault
2025-03-21 08:26:04 +01:00
Remi Collet
1c230c27ec
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  NEWS for #66049
  Fix #66049 Typemap can break parsing in parse_packet_soap leading to a segfault
2025-03-21 08:25:23 +01:00