Skip to content

Fixes #20145: free memory of certStatus before goto err #20406

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

Closed
wants to merge 6 commits into from

Conversation

mhjd
Copy link

@mhjd mhjd commented Feb 28, 2023

I have fix the issue #20145 with freeing memory of certStatus and changed the condition as asked in the issue.
I changed :

/* consume certStatus into msg right away so it gets deallocated with msg */ 
if (!sk_OSSL_CMP_CERTSTATUS_push(msg->body->value.certConf, certStatus)) 
    goto err; 

Into :

/* consume certStatus into msg right away so it gets deallocated with msg */ 
if (sk_OSSL_CMP_CERTSTATUS_push(msg->body->value.certConf, certStatus) < 1) {
/*
 * It hasn't been consumed by the msg at this point of time,
 * so we should free certStatus */
    OSSL_CMP_CERTSTATUS_free(certStatus);
    goto err;
}

@openssl-machine openssl-machine added the hold: cla required The contributor needs to submit a license agreement label Feb 28, 2023
@@ -817,8 +817,13 @@ OSSL_CMP_MSG *ossl_cmp_certConf_new(OSSL_CMP_CTX *ctx, int fail_info,
if ((certStatus = OSSL_CMP_CERTSTATUS_new()) == NULL)
goto err;
/* consume certStatus into msg right away so it gets deallocated with msg */
if (!sk_OSSL_CMP_CERTSTATUS_push(msg->body->value.certConf, certStatus))
if (sk_OSSL_CMP_CERTSTATUS_push(msg->body->value.certConf, certStatus) < 1) {
Copy link
Member

@slontis slontis Feb 28, 2023

Choose a reason for hiding this comment

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

@DDvO What frees this stack in the normal case when this passes?

Copy link
Contributor

@DDvO DDvO Mar 1, 2023

Choose a reason for hiding this comment

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

As usual with ASN.1 structures, on success ownership of field contents is passed to the containing structure, so the (stack of) OSSL_CMP_CERTSTATUS will be freed along with the msg containing it.
I even tried to make this (rather) explicit here by the comment above.

Copy link
Contributor

@DDvO DDvO left a comment

Choose a reason for hiding this comment

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

Please just remove the needless comment,
and apart from this the two fixes done here here are good.

@DDvO
Copy link
Contributor

DDvO commented Mar 1, 2023

Can we assert CLA: trivial,
like done recently for #20351?

@DDvO DDvO added branch: master Merge to master branch approval: review pending This pull request needs review by a committer approval: otc review pending branch: 3.0 Merge to openssl-3.0 branch branch: 3.1 Merge to openssl-3.1 labels Mar 1, 2023
@DDvO
Copy link
Contributor

DDvO commented Mar 1, 2023

As these fixes should be done for all versions since 3.0, I added the respective labels.

@DDvO DDvO added the triaged: bug The issue/pr is/fixes a bug label Mar 1, 2023
@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Mar 1, 2023
@DDvO
Copy link
Contributor

DDvO commented Mar 1, 2023

Can somebody explain to me why suddenly

github-actions bot added the severity: fips change The pull request changes FIPS provider sources label 2 hours ago

? So far I had assumed that this label has to do mainly with API (public header file) changes.

@mattcaswell
Copy link
Member

Can somebody explain to me why suddenly

Maybe the script is confused by the merge commits in this PR???

@github-actions github-actions bot removed the severity: fips change The pull request changes FIPS provider sources label Mar 1, 2023
@DDvO
Copy link
Contributor

DDvO commented Mar 1, 2023

Maybe the script is confused by the merge commits in this PR???

Good hint - with the but-last push, which did not actually change the actual PR contents
but maybe removed any confusing merge commits, the fips change label disappeared :)

Copy link
Contributor

@DDvO DDvO left a comment

Choose a reason for hiding this comment

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

Fine, assuming the CLA topic will be sorted out before merging.

@DDvO DDvO removed the approval: review pending This pull request needs review by a committer label Mar 1, 2023
@t8m
Copy link
Member

t8m commented Mar 1, 2023

Please drop the merge commits by git rebase -i

@t8m
Copy link
Member

t8m commented Mar 1, 2023

I would be OK with CLA: trivial for this.

@DDvO
Copy link
Contributor

DDvO commented Mar 2, 2023

In one of the CI runs, unix-macos11-m1, one of the test cases in 80-test_cmp_http.t failed with a timeout,
but I presume that this due to a timing issue on the CI machine and surely is unrelated.

@DDvO
Copy link
Contributor

DDvO commented Mar 7, 2023

I would be OK with CLA: trivial for this.

Do we need more people to agree here, or who is entitled to remove the hold: cla required?

Copy link
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

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

OK with CLA: trivial

@t8m t8m added approval: done This pull request has the required number of approvals cla: trivial One of the commits is marked as 'CLA: trivial' tests: exempted The PR is exempt from requirements for testing and removed approval: otc review pending hold: cla required The contributor needs to submit a license agreement labels Mar 7, 2023
@mattcaswell
Copy link
Member

who is entitled to remove the hold: cla required?

All reviewers and the author must agree that a contribution is trivial and then a committer is allowed to lift it.

@DDvO
Copy link
Contributor

DDvO commented Mar 7, 2023

@mhjd do you agree that the contribution is simple enough for not having to submit a CLA?
Please see the details on https://www.openssl.org/policies/cla.html and follow the instructions there.

@mhjd
Copy link
Author

mhjd commented Mar 7, 2023

@mhjd do you agree that the contribution is simple enough for not having to submit a CLA? Please see the details on https://www.openssl.org/policies/cla.html and follow the instructions there.

I agree, it's trivial, no need to submit a CLA 👌

@t8m
Copy link
Member

t8m commented Mar 8, 2023

I agree, it's trivial, no need to submit a CLA ok_hand

@mhjd Could you please use git rebase -i to drop the merge commits from the PR?

@openssl-machine
Copy link
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

@mhjd
Copy link
Author

mhjd commented Mar 9, 2023

I agree, it's trivial, no need to submit a CLA ok_hand

@mhjd Could you please use git rebase -i to drop the merge commits from the PR?

I wait the help of my professor, I have some problem with git rebase because it drop too many commits. Nevertheless I plan to retry when I have time, tomorrow or Saturday.

@paulidale paulidale added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Mar 14, 2023
@DDvO
Copy link
Contributor

DDvO commented Mar 20, 2023

I doubt this PR can really be merged in the current state, given the merge commits included.

@mhjd
Copy link
Author

mhjd commented Mar 20, 2023

Sorry for the delay, I intend to try to solve it today. (There's been a strike problem for the last few weeks so I can't ask my teacher for help).

@t8m
Copy link
Member

t8m commented Mar 20, 2023

We can resolve the problem when merging.

openssl-machine pushed a commit that referenced this pull request Mar 20, 2023
CLA: trivial

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #20406)
openssl-machine pushed a commit that referenced this pull request Mar 20, 2023
CLA: trivial

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #20406)

(cherry picked from commit c9c9901)
openssl-machine pushed a commit that referenced this pull request Mar 20, 2023
CLA: trivial

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #20406)

(cherry picked from commit c9c9901)
@t8m
Copy link
Member

t8m commented Mar 20, 2023

Merged to master, 3.1, and 3.0 branches after squashing the commits. Thank you for your contribution.

@t8m t8m closed this Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Merge to master branch branch: 3.0 Merge to openssl-3.0 branch branch: 3.1 Merge to openssl-3.1 cla: trivial One of the commits is marked as 'CLA: trivial' tests: exempted The PR is exempt from requirements for testing triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants