[php-src] master: Merge branch 'PHP-8.6'

From: Date: Tue, 24 Nov 2026 12:14:03 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-144104@lists.php.net to get a copy of this message
Author: Jakub Zelenka (bukka) Date: 2026-11-24T13:13:45+01:00 Commit: https://github.com/php/php-src/commit/039009edbdd8982b1809c3a96d528e944b848e2f Raw diff: https://github.com/php/php-src/commit/039009edbdd8982b1809c3a96d528e944b848e2f.diff Merge branch 'PHP-8.6' * PHP-8.6: Update NEWS for GH-20920 LibreSSL build fix Fix GH-20920: do not use OPENSSL_strndup() for peer CN matching Simplify php_openssl_load_all_certs_from_file() Fix GH-20920: only register PKCS7_NO_DUAL_CONTENT when it is defined Fix GH-20920: guard ENGINE_cleanup() with OPENSSL_NO_ENGINE again Changed paths: M ext/openssl/openssl.stub.php M ext/openssl/openssl_arginfo.h M ext/openssl/openssl_backend_common.c M ext/openssl/openssl_backend_v1.c M ext/openssl/xp_ssl.c Diff: diff --git a/ext/openssl/openssl.stub.php b/ext/openssl/openssl.stub.php index 3d3fa3ea634f..49e8ea9195dd 100644 --- a/ext/openssl/openssl.stub.php +++ b/ext/openssl/openssl.stub.php @@ -242,11 +242,13 @@ public function __unserialize(array $data): void {} * @cvalue PKCS7_NOCRL */ const PKCS7_NOCRL = UNKNOWN; +#ifdef PKCS7_NO_DUAL_CONTENT /** * @var int * @cvalue PKCS7_NO_DUAL_CONTENT */ const PKCS7_NO_DUAL_CONTENT = UNKNOWN; +#endif /** * @var int diff --git a/ext/openssl/openssl_arginfo.h b/ext/openssl/openssl_arginfo.h index c7fdf82c7861..a0d040ed1575 100644 --- a/ext/openssl/openssl_arginfo.h +++ b/ext/openssl/openssl_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit openssl.stub.php instead. - * Stub hash: 7cad995b734d69f98d489edb97a7878a4ea8f47e */ + * Stub hash: 28a534a72142f6813e1e93e0ed42db2c2a2cbea0 */ #include "zend_attributes.h" #include "zend_constants.h" @@ -664,7 +664,9 @@ static void register_openssl_symbols(int module_number) REGISTER_LONG_CONSTANT("PKCS7_NOSMIMECAP", PKCS7_NOSMIMECAP, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PKCS7_CRLFEOL", PKCS7_CRLFEOL, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PKCS7_NOCRL", PKCS7_NOCRL, CONST_PERSISTENT); +#if defined(PKCS7_NO_DUAL_CONTENT) REGISTER_LONG_CONSTANT("PKCS7_NO_DUAL_CONTENT", PKCS7_NO_DUAL_CONTENT, CONST_PERSISTENT); +#endif REGISTER_LONG_CONSTANT("OPENSSL_CMS_DETACHED", CMS_DETACHED, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OPENSSL_CMS_TEXT", CMS_TEXT, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OPENSSL_CMS_NOINTERN", CMS_NOINTERN, CONST_PERSISTENT); diff --git a/ext/openssl/openssl_backend_common.c b/ext/openssl/openssl_backend_common.c index 583f9a7d30b3..751061306021 100644 --- a/ext/openssl/openssl_backend_common.c +++ b/ext/openssl/openssl_backend_common.c @@ -698,6 +698,7 @@ STACK_OF(X509) *php_openssl_load_all_certs_from_file( BIO *in=NULL; X509_INFO *xi; char cert_path[MAXPATHLEN]; + int i; if (!php_openssl_check_path(cert_file, cert_file_len, cert_path, arg_num)) { goto end; @@ -716,29 +717,32 @@ STACK_OF(X509) *php_openssl_load_all_certs_from_file( goto end; } - if(!(stack = sk_X509_new_reserve(NULL, sk_X509_INFO_num(sk)))) { + if(!(stack = sk_X509_new_null())) { php_openssl_store_errors(); goto end; } /* scan over it and pull out the certs */ - while (sk_X509_INFO_num(sk)) { - xi=sk_X509_INFO_shift(sk); + for (i = 0; i < sk_X509_INFO_num(sk); i++) { + xi=sk_X509_INFO_value(sk,i); if (xi->x509 != NULL) { - sk_X509_push(stack,xi->x509); + if (!sk_X509_push(stack,xi->x509)) { + php_error_docref(NULL, E_ERROR, "Memory allocation failure"); + goto end; + } xi->x509=NULL; } - X509_INFO_free(xi); } if (!sk_X509_num(stack)) { php_error_docref(NULL, E_WARNING, "No certificates in file, %s", cert_path); - sk_X509_free(stack); goto end; } ret = stack; + stack = NULL; end: BIO_free(in); - sk_X509_INFO_free(sk); + sk_X509_INFO_pop_free(sk,X509_INFO_free); + sk_X509_pop_free(stack,X509_free); return ret; } diff --git a/ext/openssl/openssl_backend_v1.c b/ext/openssl/openssl_backend_v1.c index fc5fae4be802..10b473969255 100644 --- a/ext/openssl/openssl_backend_v1.c +++ b/ext/openssl/openssl_backend_v1.c @@ -49,8 +49,10 @@ void php_openssl_backend_shutdown(void) /* prevent accessing locking callback from unloaded extension */ CRYPTO_set_locking_callback(NULL); +#ifndef OPENSSL_NO_ENGINE /* Free engine list initialized by OPENSSL_config */ ENGINE_cleanup(); +#endif /* free allocated error strings */ ERR_free_strings(); diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index eeb267919409..9cfcadd6c0e7 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -631,11 +631,7 @@ static bool php_openssl_matches_common_name(php_stream *stream, const X509 *peer } name_asn1 = X509_NAME_ENTRY_get_data(name_entry); cert_name_len = ASN1_STRING_get_length(name_asn1); - cert_name = (unsigned char *) OPENSSL_strndup((const char *) ASN1_STRING_get0_data(name_asn1), cert_name_len); - if (cert_name == NULL) { - php_stream_warn(stream, NetworkRecvFailed, "Unable to locate peer certificate CN"); - return false; - } + cert_name = (unsigned char *) estrndup((const char *) ASN1_STRING_get0_data(name_asn1), cert_name_len); if ((size_t)cert_name_len != strlen((const char *)cert_name)) { php_stream_warn(stream, AuthFailed, "Peer certificate CN=`%.*s' is malformed", cert_name_len, (const char *)cert_name); @@ -647,7 +643,7 @@ static bool php_openssl_matches_common_name(php_stream *stream, const X509 *peer cert_name_len, (const char *)cert_name, subject_name); } - OPENSSL_free(cert_name); + efree(cert_name); return is_match; }

« previous php.cvs (#144104) next »