From f89a3503bf9435bb4a3d08360eeb89607e219f82 Mon Sep 17 00:00:00 2001 From: Giovanni Giacobbi Date: Sun, 21 Dec 2025 12:17:50 +0100 Subject: [PATCH 1/2] Use EVP_MD_CTX_destroy() instead of EVP_MD_CTX_free() for compatibility and consistency Closes GH-20748. --- NEWS | 1 + ext/phar/util.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index ad754d97bdb2e..ecdd051c5d6c2 100644 --- a/NEWS +++ b/NEWS @@ -33,6 +33,7 @@ PHP NEWS . Fixed bug GH-20732 (Phar::LoadPhar undefined behavior when reading fails). (ndossche) . Fix SplFileInfo::openFile() in write mode. (ndossche) + . Fix build on legacy OpenSSL 1.1.0 systems. (Giovanni Giacobbi) - SPL: . Fixed bug GH-20678 (resource created by GlobIterator crashes with fclose()). diff --git a/ext/phar/util.c b/ext/phar/util.c index c69f830e62805..4b9ff1cb58ba4 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -1905,7 +1905,7 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signat if (!EVP_SignInit(md_ctx, mdtype)) { EVP_PKEY_free(key); - EVP_MD_CTX_free(md_ctx); + EVP_MD_CTX_destroy(md_ctx); efree(sigbuf); if (error) { spprintf(error, 0, "unable to initialize openssl signature for phar \"%s\"", phar->fname); @@ -1916,7 +1916,7 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signat while ((sig_len = php_stream_read(fp, (char*)buf, sizeof(buf))) > 0) { if (!EVP_SignUpdate(md_ctx, buf, sig_len)) { EVP_PKEY_free(key); - EVP_MD_CTX_free(md_ctx); + EVP_MD_CTX_destroy(md_ctx); efree(sigbuf); if (error) { spprintf(error, 0, "unable to update the openssl signature for phar \"%s\"", phar->fname); @@ -1927,7 +1927,7 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signat if (!EVP_SignFinal (md_ctx, sigbuf, &siglen, key)) { EVP_PKEY_free(key); - EVP_MD_CTX_free(md_ctx); + EVP_MD_CTX_destroy(md_ctx); efree(sigbuf); if (error) { spprintf(error, 0, "unable to write phar \"%s\" with requested openssl signature", phar->fname); @@ -1937,7 +1937,7 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signat sigbuf[siglen] = '\0'; EVP_PKEY_free(key); - EVP_MD_CTX_free(md_ctx); + EVP_MD_CTX_destroy(md_ctx); #else size_t siglen; sigbuf = NULL; From 1faf17b0177fcb4572e1618475f7570110d884c3 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Sun, 21 Dec 2025 13:30:20 -0800 Subject: [PATCH 2/2] Use packed fill in scandir() (#20737) By preallocating the array to the right size and using a packed fill, we can avoid reallocations and use the fastest way to fill the array. --- ext/standard/dir.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/standard/dir.c b/ext/standard/dir.c index 918b92fab456f..7c1f8efe68875 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -558,11 +558,15 @@ PHP_FUNCTION(scandir) RETURN_FALSE; } - array_init(return_value); + array_init_size(return_value, n); + zend_hash_real_init_packed(Z_ARRVAL_P(return_value)); - for (i = 0; i < n; i++) { - add_next_index_str(return_value, namelist[i]); - } + ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) { + for (i = 0; i < n; i++) { + ZEND_HASH_FILL_SET_STR(namelist[i]); + ZEND_HASH_FILL_NEXT(); + } + } ZEND_HASH_FILL_END(); if (n) { efree(namelist);