Commit 8bc029583d6 for php

commit 8bc029583d6a2a28005a997d92032fef9438a63f
Merge: 9107cd69e85 f2faa48faee
Author: Weilin Du <weilindu@php.net>
Date:   Mon Nov 23 00:10:17 2026 +0800

    Merge branch 'PHP-8.5' into PHP-8.6

    * PHP-8.5:
      Fix GH-25528: Retain the Phar OpenSSL signing key (#25529)

diff --cc ext/phar/phar_internal.h
index 7047d10a6c7,2b243705b6d..0eaa65942cc
--- a/ext/phar/phar_internal.h
+++ b/ext/phar/phar_internal.h
@@@ -144,12 -150,12 +144,11 @@@ ZEND_BEGIN_MODULE_GLOBALS(phar
  	char*       cwd;
  	uint32_t    cwd_len;
  	bool        cwd_init;
- 	char        *openssl_privatekey;
- 	uint32_t    openssl_privatekey_len;
+ 	zend_string *openssl_privatekey;
  	/* phar_get_archive cache */
 -	char*       last_phar_name;
 -	uint32_t    last_phar_name_len;
 -	char*       last_alias;
 +	const zend_string *last_phar_name;
  	uint32_t    last_alias_len;
 +	const char* last_alias;
  	phar_archive_data* last_phar;
  	HashTable mime_types;
  ZEND_END_MODULE_GLOBALS(phar)
diff --cc ext/phar/util.c
index fafe5282fda,7f94ac6286a..773a324bf2b
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@@ -1890,11 -1940,13 +1890,11 @@@ ZEND_ATTRIBUTE_NONNULL zend_string* pha
  				mdtype = EVP_sha1();
  			}

- 			in = BIO_new_mem_buf(PHAR_G(openssl_privatekey), PHAR_G(openssl_privatekey_len));
+ 			in = PHAR_G(openssl_privatekey) ? BIO_new_mem_buf(ZSTR_VAL(PHAR_G(openssl_privatekey)), (int) ZSTR_LEN(PHAR_G(openssl_privatekey))) : NULL;

  			if (in == NULL) {
 -				if (error) {
 -					spprintf(error, 0, "unable to write to phar \"%s\" with requested openssl signature", phar->fname);
 -				}
 -				return FAILURE;
 +				spprintf(error, 0, "unable to write to phar \"%s\" with requested openssl signature", ZSTR_VAL(phar->fname));
 +				return NULL;
  			}

  			key = PEM_read_bio_PrivateKey(in, NULL,NULL, "");
@@@ -1952,13 -2012,16 +1952,14 @@@
  			siglen = 0;
  			php_stream_seek(fp, 0, SEEK_END);

- 			if (FAILURE == phar_call_openssl_sign(fp, php_stream_tell(fp), PHAR_G(openssl_privatekey), PHAR_G(openssl_privatekey_len), (char **)&sigbuf, &siglen, phar->sig_flags)) {
+ 			zend_string *privatekey = PHAR_G(openssl_privatekey);
 -			if (FAILURE == phar_call_openssl_signverify(true, fp, php_stream_tell(fp), privatekey ? ZSTR_VAL(privatekey) : NULL, privatekey ? ZSTR_LEN(privatekey) : 0, (char **)&sigbuf, &siglen, phar->sig_flags)) {
 -				if (error) {
 -					spprintf(error, 0, "unable to write phar \"%s\" with requested openssl signature", phar->fname);
 -				}
 -				return FAILURE;
++			if (FAILURE == phar_call_openssl_sign(fp, php_stream_tell(fp), privatekey ? ZSTR_VAL(privatekey) : NULL, privatekey ? ZSTR_LEN(privatekey) : 0, (char **)&sigbuf, &siglen, phar->sig_flags)) {
 +				spprintf(error, 0, "unable to write phar \"%s\" with requested openssl signature", ZSTR_VAL(phar->fname));
 +				return NULL;
  			}
 +			signature = zend_string_init((const char*)sigbuf, siglen, false);
 +			efree(sigbuf);
  #endif
 -			*signature = (char *) sigbuf;
 -			*signature_length = siglen;
  		}
  		break;
  		case PHAR_SIG_SHA1: {