Skip to content

Commit 20c274b

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents 62e30ec + e46f77c commit 20c274b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ PHP NEWS
2121
. Fixed bug GH-19485 (potential use after free when using persistent pgsql
2222
connections). (Mark Karpeles)
2323

24+
- Phar:
25+
. Fixed memory leaks when verifying OpenSSL signature. (Girgias)
26+
2427
- Standard:
2528
. Fixed bug GH-16649 (UAF during array_splice). (alexandre-daubois)
2629

ext/phar/util.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,7 @@ zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char
19521952

19531953
if (!EVP_SignInit(md_ctx, mdtype)) {
19541954
EVP_PKEY_free(key);
1955+
EVP_MD_CTX_free(md_ctx);
19551956
efree(sigbuf);
19561957
if (error) {
19571958
spprintf(error, 0, "unable to initialize openssl signature for phar \"%s\"", phar->fname);
@@ -1962,6 +1963,7 @@ zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char
19621963
while ((sig_len = php_stream_read(fp, (char*)buf, sizeof(buf))) > 0) {
19631964
if (!EVP_SignUpdate(md_ctx, buf, sig_len)) {
19641965
EVP_PKEY_free(key);
1966+
EVP_MD_CTX_free(md_ctx);
19651967
efree(sigbuf);
19661968
if (error) {
19671969
spprintf(error, 0, "unable to update the openssl signature for phar \"%s\"", phar->fname);
@@ -1972,6 +1974,7 @@ zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char
19721974

19731975
if (!EVP_SignFinal (md_ctx, sigbuf, &siglen, key)) {
19741976
EVP_PKEY_free(key);
1977+
EVP_MD_CTX_free(md_ctx);
19751978
efree(sigbuf);
19761979
if (error) {
19771980
spprintf(error, 0, "unable to write phar \"%s\" with requested openssl signature", phar->fname);
@@ -1981,7 +1984,7 @@ zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char
19811984

19821985
sigbuf[siglen] = '\0';
19831986
EVP_PKEY_free(key);
1984-
EVP_MD_CTX_destroy(md_ctx);
1987+
EVP_MD_CTX_free(md_ctx);
19851988
#else
19861989
size_t siglen;
19871990
sigbuf = NULL;

0 commit comments

Comments
 (0)