Commit 0c6b9e2ff6e for php

commit 0c6b9e2ff6e63e97557e61cd338f458216fa7491
Merge: ee66611f6eb 6e44b00c55b
Author: Jakub Zelenka <bukka@php.net>
Date:   Tue Nov 24 13:13:09 2026 +0100

    Merge branch 'PHP-8.5' into PHP-8.6

    * PHP-8.5:
      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

diff --cc NEWS
index ec4638803c1,e0c63784980..f190689eff4
--- a/NEWS
+++ b/NEWS
@@@ -132,17 -118,10 +132,19 @@@ PH
      arrays. (Weilin Du)
    . Fixed function JIT ASSIGN_DIM reporting an undefined value or key out of
      order, or when the VM does not, on non-array containers. (Jorg Sowa)
 +  . Fixed bug GH-25449 (Element of a by-reference function result passed as
 +    an argument arrives as null). (Ilia Alshanetsky)

  - OpenSSL:
 +  . Fixed bug GH-25172 (TLS session reuse shares request-lifetime callback
 +    structures with persistent streams). (cxxz16, David Carlier)
 +  . Fixed an exception thrown by the session_get_cb stream context callback
 +    being replaced with a TypeError. (Ilia Alshanetsky)
 +  . Fixed use-after-free when a stream is closed by the callback for
 +    `early_data_cb`, `psk_client_cb`, `psk_server_cb`, `session_get_cb`, or
 +    `session_new_cb`. (DanielEScherzer)
+   . Fixed bug GH-20920 (LibreSSL build regression with PHP 8.5).
+     (Eugene Gvozdetsky, Theo Buehler, Jakub Zelenka)

  - PDO_Firebird:
    . Fixed stack buffer overflow with long connection user names, passwords,
diff --cc ext/openssl/openssl_arginfo.h
index c7fdf82c786,4247aad7617..a0d040ed157
Binary files differ
diff --cc ext/openssl/xp_ssl.c
index 03ac2304c6e,c36e9e9adc2..72ec45149b8
--- a/ext/openssl/xp_ssl.c
+++ b/ext/openssl/xp_ssl.c
@@@ -626,28 -563,29 +626,24 @@@ static bool php_openssl_matches_common_

  	name_entry = X509_NAME_get_entry(name, name_index);
  	if (name_entry == NULL) {
 -		php_error_docref(NULL, E_WARNING, "Unable to locate peer certificate CN");
 +		php_stream_warn(stream, NetworkRecvFailed, "Unable to locate peer certificate CN");
  		return false;
  	}
 -
  	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_error_docref(NULL, E_WARNING, "Peer certificate CN=`%.*s' is malformed", cert_name_len, (const char *)cert_name);
 -		efree(cert_name);
 -		return false;
 +		php_stream_warn(stream, AuthFailed, "Peer certificate CN=`%.*s' is malformed", cert_name_len, (const char *)cert_name);
  	} else if (php_openssl_matches_wildcard_name(subject_name, (const char *)cert_name)) {
 -		is_match = 1;
 +		is_match = true;
  	} else {
 -		php_error_docref(NULL, E_WARNING,
 +		php_stream_warn(stream, AuthFailed,
  			"Peer certificate CN=`%.*s' did not match expected CN=`%s'",
  			cert_name_len, (const char *)cert_name, subject_name);
 -		efree(cert_name);
 -		return false;
  	}

- 	OPENSSL_free(cert_name);
+ 	efree(cert_name);

  	return is_match;
  }