Skip to content

Commit e27c436

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 414e521 + 20c274b commit e27c436

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
@@ -37,6 +37,9 @@ PHP NEWS
3737
. Implement #81724 (openssl_cms_encrypt only allows specific ciphers).
3838
(Jakub Zelenka)
3939

40+
- Phar:
41+
. Fixed memory leaks when verifying OpenSSL signature. (Girgias)
42+
4043
- Session:
4144
. Added support for partitioned cookies. (nielsdos)
4245

ext/phar/util.c

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

19221922
if (!EVP_SignInit(md_ctx, mdtype)) {
19231923
EVP_PKEY_free(key);
1924+
EVP_MD_CTX_free(md_ctx);
19241925
efree(sigbuf);
19251926
if (error) {
19261927
spprintf(error, 0, "unable to initialize openssl signature for phar \"%s\"", phar->fname);
@@ -1931,6 +1932,7 @@ zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char
19311932
while ((sig_len = php_stream_read(fp, (char*)buf, sizeof(buf))) > 0) {
19321933
if (!EVP_SignUpdate(md_ctx, buf, sig_len)) {
19331934
EVP_PKEY_free(key);
1935+
EVP_MD_CTX_free(md_ctx);
19341936
efree(sigbuf);
19351937
if (error) {
19361938
spprintf(error, 0, "unable to update the openssl signature for phar \"%s\"", phar->fname);
@@ -1941,6 +1943,7 @@ zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char
19411943

19421944
if (!EVP_SignFinal (md_ctx, sigbuf, &siglen, key)) {
19431945
EVP_PKEY_free(key);
1946+
EVP_MD_CTX_free(md_ctx);
19441947
efree(sigbuf);
19451948
if (error) {
19461949
spprintf(error, 0, "unable to write phar \"%s\" with requested openssl signature", phar->fname);
@@ -1950,7 +1953,7 @@ zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char
19501953

19511954
sigbuf[siglen] = '\0';
19521955
EVP_PKEY_free(key);
1953-
EVP_MD_CTX_destroy(md_ctx);
1956+
EVP_MD_CTX_free(md_ctx);
19541957
#else
19551958
size_t siglen;
19561959
sigbuf = NULL;

0 commit comments

Comments
 (0)