diff --git a/NEWS b/NEWS index 9e4ff26e0fa..21390d1cca1 100644 --- a/NEWS +++ b/NEWS @@ -37,6 +37,9 @@ PHP NEWS . Implement #81724 (openssl_cms_encrypt only allows specific ciphers). (Jakub Zelenka) +- Phar: + . Fixed memory leaks when verifying OpenSSL signature. (Girgias) + - Session: . Added support for partitioned cookies. (nielsdos) diff --git a/ext/phar/util.c b/ext/phar/util.c index 06394813574..aa30515eff6 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -1921,6 +1921,7 @@ zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char if (!EVP_SignInit(md_ctx, mdtype)) { EVP_PKEY_free(key); + EVP_MD_CTX_free(md_ctx); efree(sigbuf); if (error) { 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 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); efree(sigbuf); if (error) { 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 if (!EVP_SignFinal (md_ctx, sigbuf, &siglen, key)) { EVP_PKEY_free(key); + EVP_MD_CTX_free(md_ctx); efree(sigbuf); if (error) { 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 sigbuf[siglen] = '\0'; EVP_PKEY_free(key); - EVP_MD_CTX_destroy(md_ctx); + EVP_MD_CTX_free(md_ctx); #else size_t siglen; sigbuf = NULL;