Skip to content

[SOAP] Fix WSDL cache corruption when header defines headerfaults - #23502

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/sdl-headerfault-cache-mkj-84
Open

[SOAP] Fix WSDL cache corruption when header defines headerfaults#23502
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/sdl-headerfault-cache-mkj-84

Conversation

@iliaal

@iliaal iliaal commented Aug 29, 2026

Copy link
Copy Markdown
Member

sdl_serialize_soap_body() counted j headerfaults per header but serialized
the body->headers hash table instead of tmp->headerfaults, writing N header
records where the deserializer expects j fault records. Any soap:header with
soap:headerfault children misaligns the WSDL cache stream; loading the cached
SDL segfaults. Reproduced with two headers, one headerfault each, on a second
cache-hitting SoapClient construction. The inner loop now iterates
tmp->headerfaults. No other loop in php_sdl.c mismatches.

Comment thread ext/soap/tests/headerfault_cache.phpt Outdated
soap.wsdl_cache_enabled=1
--FILE--
<?php
$dir = sys_get_temp_dir() . '/wsdlcache' . getmypid();

@devnexen devnexen Aug 29, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every time a resource is created, database, temp files ... a clean section is needed so if the test fails before the ends it gets clean up no matters what.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

Comment thread ext/soap/php_sdl.c
const zend_string *key_inner;

ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(body->headers, key_inner, tmp2) {
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(tmp->headerfaults, key_inner, tmp2) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine fix, however then the cache needs a bump (WSDL_CACHE_VERSION) -> 0x11

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumped to 0x11.

sdl_serialize_soap_body() counted j headerfaults per header but then
serialized body->headers instead of tmp->headerfaults, writing N header
records where j fault records were expected by sdl_deserialize_soap_body(),
misaligning the cache stream and crashing on load whenever a soap:header
carries headerfaults. Iterate tmp->headerfaults instead; sibling audit of
the other serialize/deserialize loops in php_sdl.c found no further
hash-mismatched iteration. Bump WSDL_CACHE_VERSION so existing on-disk
caches are discarded.
@iliaal
iliaal force-pushed the fix/sdl-headerfault-cache-mkj-84 branch from e71448f to 852426e Compare August 29, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants