Skip to content

Commit f75ad03

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix crash in php_openssl_pkey_init_ec() when EVP_PKEY_CTX_new() fails Fix memory leak in check_cert() when X509_STORE_CTX_init() fails Fix NPD when i2d_PKCS12_bio is called on NULL bio
2 parents 880a6fc + 6b16390 commit f75ad03

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

ext/openssl/openssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ PHP_FUNCTION(openssl_pkcs12_export)
14431443

14441444
if (p12 != NULL) {
14451445
bio_out = BIO_new(BIO_s_mem());
1446-
if (i2d_PKCS12_bio(bio_out, p12)) {
1446+
if (bio_out && i2d_PKCS12_bio(bio_out, p12)) {
14471447
BUF_MEM *bio_buf;
14481448

14491449
BIO_get_mem_ptr(bio_out, &bio_buf);

ext/openssl/openssl_backend_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ int php_openssl_check_cert(X509_STORE *ctx, X509 *x, STACK_OF(X509) *untrustedch
748748
return 0;
749749
}
750750
if (!X509_STORE_CTX_init(csc, ctx, x, untrustedchain)) {
751+
X509_STORE_CTX_free(csc);
751752
php_openssl_store_errors();
752753
php_error_docref(NULL, E_WARNING, "Certificate store initialization failed");
753754
return 0;

ext/openssl/openssl_backend_v3.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ EVP_PKEY *php_openssl_pkey_init_ec(zval *data, bool *is_private) {
454454
}
455455
EVP_PKEY_CTX_free(ctx);
456456
ctx = EVP_PKEY_CTX_new(param_key, NULL);
457+
if (!ctx) {
458+
goto cleanup;
459+
}
457460
}
458461

459462
if (EVP_PKEY_check(ctx) || EVP_PKEY_public_check_quick(ctx)) {

0 commit comments

Comments
 (0)