[php-src] PR #22040: ext/openssl: Free prior SSL_SESSION on Openssl\Session::__unserialize
| From: | iliaal | Date: | Wed, 13 May 2026 20:32:33 +0000 |
| Subject: | [php-src] PR #22040: ext/openssl: Free prior SSL_SESSION on Openssl\Session::__unserialize | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36121@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22040
Author: iliaal
Openssl\Session::__unserialize() overwrites obj->session without
freeing the previous SSL_SESSION when called twice on the same instance. The
SSL_SESSION lives in OpenSSL's allocator and bypasses memory_limit,
so a long-running worker that exercises the repeat path accumulates an unbounded leak. The readonly
$id property guards the userland-visible state on the second call by throwing, but the
C-side overwrite at openssl.c:459 runs before that throw. Free the prior session when
obj->session is already populated.
The regression test exercises the repeat-unserialize path and asserts the throw plus the surviving
process state. It still produces one 64-byte zend_string leak under
--enable-debug because of a separate engine bug in
zend_update_property_string{,l} fixed in php/php-src#22039. The leak this PR fixes is
on the OpenSSL allocator side and is caught by the ASan matrix.