Skip to content

Fix missing error propagation in openssl_x509_export_to_file()#21348

Open
ndossche wants to merge 2 commits intophp:PHP-8.4from
ndossche:clesss-30
Open

Fix missing error propagation in openssl_x509_export_to_file()#21348
ndossche wants to merge 2 commits intophp:PHP-8.4from
ndossche:clesss-30

Conversation

@ndossche
Copy link
Member

@ndossche ndossche commented Mar 5, 2026

The file writes can have failed, but this error isn't visible for the application, fix it by propagating the error properly.

This was found by a hybrid static-dynamic analyser that looks for inconsistent handling of error checks in bindings.

The file writes can have failed, but this error isn't visible for the
application, fix it by propagating the error properly.
goto exit_cleanup_bio;
}

RETVAL_TRUE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RETVAL_TRUE;
if (!notext && !X509_print(bio_out, cert) && !PEM_write_bio_X509(bio_out, cert)) {
php_openssl_store_errors();
} else {
RETVAL_TRUE;
}

Something like this is probably better than goto...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sorry that applies notext, so maybe just some if / else if / else in that case

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed a variant of this

@ndossche ndossche requested a review from bukka March 5, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants