-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix potential memory leak in EC multiplication #3318
Conversation
Signed-off-by: Jonas <[email protected]>
Thanks for the bug report and the fix! Please add a changelog entry file. Would you mind adding a test case to |
Signed-off-by: Jonas <[email protected]>
Signed-off-by: Jonas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the tests requested by Gilles. Looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding a non-regression test!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me as well. I just have a suggestion though.
@@ -2278,7 +2281,10 @@ static int ecp_randomize_mxz( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P | |||
MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &l, 1 ) ); | |||
|
|||
if( count++ > 10 ) | |||
return( MBEDTLS_ERR_ECP_RANDOM_FAILED ); | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about to do this change @ line 2859 (line number in the initial version of the file) as well:
if( ++count > 30 )
return( MBEDTLS_ERR_ECP_RANDOM_FAILED );
ret = mbedtls_mpi_lt_mpi_ct( d, &grp->N, &cmp );
if( ret != 0 )
{
goto cleanup;
}
I can see that there is no clean-up to do here (currently) but this would align with the code just below.
Signed-off-by: Jonas <[email protected]>
Signed-off-by: Jonas <[email protected]>
@@ -0,0 +1,3 @@ | |||
Bugfix | |||
* Fix potential memory leaks in ecp_randomize_jac() and ecp_randomize_mxz() | |||
when PRNG function fails. Contributed by Jonas Lejeune in #3317. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not noticing earlier: I think this should be 3318.
Signed-off-by: Jonas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing the ChangeLog entry (and uniformizing error handling). Looks good to me.
Note: the only failure in the CI is a failure to clone the repo in the freebsd part of the pr-merge job. Clearly this is an infrastructure glitch unrelated to this PR, so not a blocker for merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for addressing my comment.
Signed-off-by: Jonas <[email protected]>
Signed-off-by: Jonas <[email protected]>
Signed-off-by: Jonas [email protected]
Description
Fix memory leak issue with EC multiplication described in #3317
Backports: 2.16: #3352; 2.7: #3353