Skip to content

Properly propagate failure of X509_STORE_CTX_new() - #22625

Merged
ndossche merged 1 commit into
php:masterfrom
ndossche:openssl-e-error
Aug 3, 2026
Merged

Properly propagate failure of X509_STORE_CTX_new()#22625
ndossche merged 1 commit into
php:masterfrom
ndossche:openssl-e-error

Conversation

@ndossche

@ndossche ndossche commented Jul 7, 2026

Copy link
Copy Markdown
Member

Propagating is consistent with other "new" failures, and avoids bailing out, which is inherently problematic anyway as it can cause persistent leaks on its own.

Originally reported as a part of #21643, but the other issues there are all semantic whereas this is specific to ASAN.

Propagating is consistent with other "new" failures, and avoids bailing out,
which is inherently problematic anyway as it can cause persistent leaks
on its own.
@ndossche
ndossche requested a review from bukka as a code owner July 7, 2026 11:57
@ndossche ndossche changed the title Properly propagate X509_STORE_CTX_new() Properly propagate failure of X509_STORE_CTX_new() Jul 7, 2026
@ndossche
ndossche requested a review from Girgias August 3, 2026 13:27
if (csc == NULL) {
php_openssl_store_errors();
php_error_docref(NULL, E_ERROR, "Memory allocation failure");
php_error_docref(NULL, E_WARNING, "Memory allocation failure");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess it's basically impossible to create a test for this, but as I'm unfamilar with openssl, I'm assuming that the call to X509_STORE_CTX_new doesn't store any relevant error, so that's why we need the extra warning?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It will store an error that can be looked at via the error queue.
However, ext/openssl is inconsistent: in some cases only the error in the error queue is stored and in other cases an additional warning is emitted

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Okay, well pre-exiting behaviour so lets just leave it like that then.

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Always in favour of getting rid of a bailout.

@ndossche
ndossche merged commit decc156 into php:master Aug 3, 2026
18 checks passed
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