Skip to content

Commit fd61270

Browse files
committed
Fix missing error propagation in openssl_x509_export_to_file()
The file writes can have failed, but this error isn't visible for the application, fix it by propagating the error properly.
1 parent 94853b6 commit fd61270

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ext/openssl/openssl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,9 +1569,11 @@ PHP_FUNCTION(openssl_x509_export_to_file)
15691569
if (bio_out) {
15701570
if (!notext && !X509_print(bio_out, cert)) {
15711571
php_openssl_store_errors();
1572+
goto exit_cleanup_bio;
15721573
}
15731574
if (!PEM_write_bio_X509(bio_out, cert)) {
15741575
php_openssl_store_errors();
1576+
goto exit_cleanup_bio;
15751577
}
15761578

15771579
RETVAL_TRUE;
@@ -1580,6 +1582,7 @@ PHP_FUNCTION(openssl_x509_export_to_file)
15801582
php_error_docref(NULL, E_WARNING, "Error opening file %s", file_path);
15811583
}
15821584

1585+
exit_cleanup_bio:
15831586
if (!BIO_free(bio_out)) {
15841587
php_openssl_store_errors();
15851588
}

0 commit comments

Comments
 (0)