1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

283 Commits

Author SHA1 Message Date
Gina Peter Banyard
f40b356ad9 Use smart_str_append() if we have a zend_string* (#21414) 2026-03-21 17:06:14 +00:00
David CARLIER
b0aa6b9626 ext/soap: various optimisations
* replace strcat/strncpy with memcpy for pre-allocated buffers.
* remove redundant memset before struct copy.
2026-03-12 17:56:43 +00:00
David Carlier
ed887241be Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/soap: Fix wrong cookie options offset calculation, using separator offset instead.
2026-03-10 22:01:03 +00:00
David Carlier
f04873c1b8 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/soap: Fix wrong cookie options offset calculation, using separator offset instead.
2026-03-10 21:59:38 +00:00
David Carlier
1b61d555fb ext/soap: Fix wrong cookie options offset calculation, using separator offset instead.
The cookie option parser uses a wrong offset to start scanning
attributes, causing cookie values containing substrings like
"path=" or "domain=" to be falsely matched as attributes.

close GH-21400
2026-03-10 21:58:52 +00:00
David CARLIER
e929602ed0 ext/soap: HTTP request micro optimisations. (#20516)
smart string is a bit overkill for the cookie id here.
2025-11-18 18:32:59 +00:00
Niels Dossche
8ea4d7b5fa Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix uninitialized soap lang_en string on ZTS
2025-09-29 16:11:47 +02:00
Niels Dossche
8987c0b661 Fix uninitialized soap lang_en string on ZTS
Replaces GH-19772.
Closes GH-19772.
Fixes GH-19773.
Closes GH-19819.
2025-09-29 16:11:29 +02:00
Tim Düsterhus
45bbe8c36d soap: Use return true / return false for functions returning bool
Changes done with Coccinelle:

    @r1@
    identifier fn;
    typedef bool;
    symbol false;
    symbol true;
    @@

    bool fn ( ... )
    {
    <...
    return
    (
    - 0
    + false
    |
    - 1
    + true
    )
    ;
    ...>
    }

Coccinelle patch sourced from
torvalds/linux@46b5c9b856.
2025-09-24 18:51:40 +02:00
Tim Düsterhus
59f2228667 soap: Use true / false instead of 1 / 0 when assigning to bool
Changes done with Coccinelle:

    @@
    bool b;
    @@

    - b = 0
    + b = false

    @@
    bool b;
    @@

    - b = 1
    + b = true
2025-09-24 18:51:40 +02:00
Tim Düsterhus
26eac7de17 uri: Clean up naming of public symbols (#19794)
* uri: Rename `uri_recomposition_mode_t` to `php_uri_recomposition_mode`

* uri: Align the names of the `php_uri_recomposition_mode` values

* uri: Rename `uri_component_read_mode_t` to `php_uri_component_read_mode`

* uri: Align the names of the `php_uri_component_read_mode` values

* uri: Rename `uri_property_name_t` to `php_uri_property_name`

* uri: Align the names of the `php_uri_property_name` values

* uri: Rename `uri_property_handler_t` to `php_uri_property_handler`

* uri: Rename `uri_(read|write)_t` to `php_uri_property_handler_(read|write)`

* uri: Rename `php_uri_property_handler`’s `(read|write)_func` to `read|write`

The `_func` is implied by the data type and the name of the struct.

* uri: Rename `uri_parser_t` to `php_uri_parser`

* uri: Shorten the names of `php_uri_parser` fields

The `_uri` suffix is implied, because this is an URI parser.
2025-09-11 12:10:41 +02:00
Tim Düsterhus
1faaa7224d uri: Remove useless layer of indirection in php_uri_get_parser() (#19774)
By using the `zend_hash_*()` functions directly, we can benefit from the
precalculated hash value in the given `zend_string *uri_parser_name`. We need
to deconstify the parameter, since the function might calculate the hash, thus
modifying the `zend_string*`.
2025-09-09 22:02:30 +02:00
Tim Düsterhus
49faa4df75 uri: Always use const pointers when referring to uri_parser_t (#19623)
The actual parser definitions are all `const` and must never be modified. Make
sure to always use `const` pointers.
2025-08-30 21:04:50 +02:00
Máté Kocsis
e9c92a9739 ext/uri: Use the term "URI parser" instead of "URI handler" (#19530) 2025-08-21 07:23:47 +02:00
Máté Kocsis
1cff1815d0 Add internal URI handling API (#19073)
Part of https://github.com/php/php-src/pull/14461. Related to https://wiki.php.net/rfc/url_parsing_api.
2025-08-19 18:35:09 +02: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
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
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
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
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
Niels Dossche
ce3869b547 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix Soap leaking http_msg on error
2024-10-06 17:59:49 +02:00
Niels Dossche
a9dada29e7 Fix Soap leaking http_msg on error
Testing all cases is not so easy to do as we would need a server that
redirects from e.g. http to https while SSL is not available.

Closes GH-16254.
2024-10-06 17:58:28 +02:00
Niels Dossche
520fce5607 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix bug #73182: PHP SOAPClient does not support stream context HTTP headers in array form
2024-09-10 20:24:57 +02:00
Niels Dossche
72a2cbcc7f Fix bug #73182: PHP SOAPClient does not support stream context HTTP headers in array form
This code is modelled after how `http_fopen_wrapper.c` does things,
which apparently is just looping over the array and handling each string
the same way as if we passed a header string directly.

Also fixes a potential crash in `php_sdl.c` but without adding support
for header arrays there (yet) because the code is untested.

Closes GH-15817.
2024-09-10 20:24:14 +02:00
Niels Dossche
7771ec07e5 Fix bug #61525: SOAP functions require at least one space after HTTP header colon
HTTP/1.1 does not require a single whitespace after the colon, and
SoapServer does implement HTTP/1.1. The header value is already correctly
whitespace-trimmed, so no behaviour change happens w.r.t. header values.

Closes GH-15793.
2024-09-08 10:42:30 +02:00
Niels Dossche
7d99a9cea1 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix bug #55639: Digest autentication dont work
2024-07-17 19:35:19 +02:00
Niels Dossche
911dc5b46c Fix bug #55639: Digest autentication dont work
RFC 2617 and 7616 describe that for the "Authorization" header we should
not put the qop nor nc value inside quotes. This differs from the
WWW-Authenticate header, which may have been the source of the confusion
in the implementation. While the version with quotes seems to work fine
in some cases, clearly not all servers accept the non-standard form.
To fix the issue, simply removing the quotes of those two header fields
of the client request to be in line with the RFC suffices.

I refer further to example 3.5 in RFC 2617 and example 3.9.1 in
RFC 7616.

RFC 2617: https://datatracker.ietf.org/doc/html/rfc2617
RFC 7616: https://datatracker.ietf.org/doc/html/rfc7616

Closes GH-14328.
2024-07-17 19:23:10 +02:00
Gina Peter Banyard
1e7134f07f ext/soap: Refactor implementation of in_domain() 2024-06-19 02:20:36 +01:00
Gina Peter Banyard
fd2d869642 Clean-up some more headers (#14416)
Remove unused headers (such as php_ini.h for extensions that don't define INI settings)
Use more specific headers when possible
2024-06-08 17:15:36 +01:00
Niels Dossche
ffe225d686 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix bug #76232: SoapClient Cookie Header Semicolon
2024-06-01 17:38:06 +02:00
Niels Dossche
1b1677a8f1 Fix bug #76232: SoapClient Cookie Header Semicolon
According to RFC 6265 [1] the cookies must be separated by "; " not ";",
and it must not end with ";".

[1] https://datatracker.ietf.org/doc/html/rfc6265

Closes GH-14406.
2024-06-01 17:37:30 +02:00
Niels Dossche
acfa564e72 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix bug #47925 again (#14348)
  Fix GH-14343: Memory leak in xml and dom (#14347)
2024-05-29 17:52:00 +02:00
Niels Dossche
ce7ed6e040 Fix bug #47925 again (#14348)
The naming of the userland functions is terrible and confused me.
gzdecode() is actually the function to decompress a gzip stream, and
gzuncompress() is the one to decompress a deflate stream...
See zlib.c to see the internal function -> type mapping.
2024-05-29 17:50:20 +02:00
Niels Dossche
8896bd3200 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix bug #47925: PHPClient can't decompress response (transposed uncompress methods?)
2024-05-27 19:24:18 +02:00
Niels Dossche
35e62e9b59 Fix bug #47925: PHPClient can't decompress response (transposed uncompress methods?)
The incorrect functions are being called to deal with incoming
compressed data.
gzip/x-gzip corresponds to gzuncompress(), while deflate corresponds to
gzinflate().

The existing code for gzip compression also plays with removing the
first 10 bytes (i.e. the gzip header) to pass it to the inflate
implementation but that doesn't always work properly due to trailer
data. Get rid of that entirely by using the correct functions.

Closes GH-14321.
2024-05-27 19:23:40 +02:00
Máté Kocsis
44b3cb2a13 Migrate SOAP URL resource to object
Related to https://wiki.php.net/rfc/resource_to_object_conversion and https://github.com/php/php-tasks/issues/6
2024-05-07 09:21:39 +02:00
Tim Düsterhus
97b3b4552d random: Move CSPRNG API into php_random_csprng.h (#13290)
This allows consumers of just the CSPRNG to include a much smaller header. It
also allows to verify at a glance whether a source file might use non-secure
randomness.

This commit includes the new header wherever the CSPRNG is used, possibly
replacing the inclusion of php_random.h if nothing else is used, but also
includes it in the main php_random.h header for compatibility.

Somewhat related to 45f8cfaf10,
2b30f18708, and
b14dd85dca.
2024-02-01 19:09:35 +01:00
Niels Dossche
92e4e8bdf4 Fix #49278: SoapClient::__getLastResponseHeaders returns NULL if wsdl operation !has output
Instead of early exiting, process the headers if tracing is enabled, and
exit after that.

Closes GH-12609.
2023-11-06 19:04:15 +01:00
Pierrick Charron
38e4e58f42 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Update NEWS
  Update NEWS
  Fix GH-11382 add missing hash header for bin2hex
  Fix missing randomness check and insufficient random bytes for SOAP HTTP Digest
2023-06-06 18:07:19 -04:00
Pierrick Charron
a5b8bfce7c Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Update NEWS
  Fix GH-11382 add missing hash header for bin2hex
  Fix missing randomness check and insufficient random bytes for SOAP HTTP Digest
2023-06-06 18:01:56 -04:00
Remi Collet
0572448263 Fix GH-11382 add missing hash header for bin2hex 2023-06-06 17:56:19 -04:00
Niels Dossche
ac4254ad76 Fix missing randomness check and insufficient random bytes for SOAP HTTP Digest
If php_random_bytes_throw fails, the nonce will be uninitialized, but
still sent to the server. The client nonce is intended to protect
against a malicious server. See section 5.10 and 5.12 of RFC 7616 [1],
and bullet point 2 below.

Tim pointed out that even though it's the MD5 of the nonce that gets sent,
enumerating 31 bits is trivial. So we have still a stack information leak
of 31 bits.

Furthermore, Tim found the following issues:
* The small size of cnonce might cause the server to erroneously reject
  a request due to a repeated (cnonce, nc) pair. As per the birthday
  problem 31 bits of randomness will return a duplication with 50%
  chance after less than 55000 requests and nc always starts counting at 1.
* The cnonce is intended to protect the client and password against a
  malicious server that returns a constant server nonce where the server
  precomputed a rainbow table between passwords and correct client response.
  As storage is fairly cheap, a server could precompute the client responses
  for (a subset of) client nonces and still have a chance of reversing the
  client response with the same probability as the cnonce duplication.

  Precomputing the rainbow table for all 2^31 cnonces increases the rainbow
  table size by factor 2 billion, which is infeasible. But precomputing it
  for 2^14 cnonces only increases the table size by factor 16k and the server
  would still have a 10% chance of successfully reversing a password with a
  single client request.

This patch fixes the issues by increasing the nonce size, and checking
the return value of php_random_bytes_throw(). In the process we also get
rid of the MD5 hashing of the nonce.

[1] RFC 7616: https://www.rfc-editor.org/rfc/rfc7616

Co-authored-by: Tim Düsterhus <timwolla@php.net>
2023-06-06 17:53:45 -04:00
Go Kudo
4d8dd8d258 Implement Random Extension
https://wiki.php.net/rfc/rng_extension
https://wiki.php.net/rfc/random_extension_improvement
2022-07-19 10:27:38 +01:00