Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added NULL check to BN_clear() & BN_CTX_end() #8518

Closed
wants to merge 1 commit into from

Conversation

slontis
Copy link
Member

@slontis slontis commented Mar 19, 2019

BN_clear_free & BN_CTX_free() both do a NULL check, so it makes sense to also do the NULL
check inside BN_clear() and BN_CTX_end() since these are commonly called at the end of a function in a similar location to the free calls.

BN_clear() is only used in new code so this is not much of a change.
BN_CTX_end() is commonly called before BN_CTX_free() and quite often already does the NULL check
(so moving it inside the function should not be too much overhead). The normal case is that it is not NULL so calling the function is normally required.

This cleanup addresses quite a few coverity issues (in RSA code related to both BN_clear & BN_CTX_end)

Checklist
  • documentation is added or updated
  • tests are added or updated

@slontis slontis mentioned this pull request Mar 19, 2019
2 tasks
@paulidale paulidale added the branch: master Merge to master branch label Mar 19, 2019
@paulidale
Copy link
Contributor

Is it worthwhile making this change in 1.1.1 too? Just to keep the code more in sync.

@paulidale paulidale added the approval: review pending This pull request needs review by a committer label Mar 19, 2019
@InfoHunter
Copy link
Member

Is it worthwhile making this change in 1.1.1 too?

I agree. Thus later patches using these functions will be consistent when they are being ported back to 1.1.1

@paulidale paulidale added the branch: 1.1.1 Merge to OpenSSL_1_1_1-stable branch label Mar 19, 2019
Copy link
Member

@levitte levitte left a comment

Choose a reason for hiding this comment

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

Yup, and agreed on 1.1.1. I can merge

@levitte levitte added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Mar 19, 2019
levitte pushed a commit that referenced this pull request Mar 19, 2019
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from #8518)
levitte pushed a commit that referenced this pull request Mar 19, 2019
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from #8518)

(cherry picked from commit ce1415e)
@levitte
Copy link
Member

levitte commented Mar 19, 2019

Merged.

master:
ce1415e Added NULL check to BN_clear() & BN_CTX_end()

1.1.1:
c8a9fa6 Added NULL check to BN_clear() & BN_CTX_end()

@levitte levitte closed this Mar 19, 2019
@richsalz
Copy link
Contributor

Very nice. Now do a PR to update the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: done This pull request has the required number of approvals branch: master Merge to master branch branch: 1.1.1 Merge to OpenSSL_1_1_1-stable branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants