Skip to content

x509attr: check for errors of sk_ASN1_TYPE_push() & use reserve call#1034

Open
ndossche wants to merge 2 commits intoruby:masterfrom
ndossche:clesss-9
Open

x509attr: check for errors of sk_ASN1_TYPE_push() & use reserve call#1034
ndossche wants to merge 2 commits intoruby:masterfrom
ndossche:clesss-9

Conversation

@ndossche
Copy link
Copy Markdown
Contributor

See individual commits.

This function returns 0 on error. The main error condition is reallocation, so use a reserve call to avoid reallocations as well.

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

This function returns 0 on error.
Comment thread ext/openssl/ossl_x509attr.c Outdated
GetX509Attr(self, attr);
count = X509_ATTRIBUTE_count(attr);
/* there is no X509_ATTRIBUTE_get0_set() :( */
#if OSSL_OPENSSL_PREREQ(3, 0, 0)
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.

Could you check the availability of the function in ext/openssl/extconf.rb instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll do that after lunch. THanks, I'm relatively new to Ruby extension development so wasn't familiar with this.

This should avoid reallocations and prevent the main error condition of
the push call.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants