Skip to content

Commit

Permalink
Merge pull request #6583 from aditya-deshpande-arm/bugfix-dh_genprime
Browse files Browse the repository at this point in the history
[Backport 2.28] dh_genprime: Fix issue where the error code returned by mbedtls_mpi_write_file() is incorrectly reported on failure
  • Loading branch information
gilles-peskine-arm authored Nov 15, 2022
2 parents 8d82664 + f22f73e commit 0fcc1cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.d/fix_dh_genprime_error_reporting.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Bugfix
* Fix bug in error reporting in dh_genprime.c where upon failure,
the error code returned by mbedtls_mpi_write_file() is overwritten
and therefore not printed.
4 changes: 2 additions & 2 deletions programs/pkey/dh_genprime.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ int main( int argc, char **argv )
goto exit;
}

if( ( ret = mbedtls_mpi_write_file( "P = ", &P, 16, fout ) != 0 ) ||
( ret = mbedtls_mpi_write_file( "G = ", &G, 16, fout ) != 0 ) )
if( ( ( ret = mbedtls_mpi_write_file( "P = ", &P, 16, fout ) ) != 0 ) ||
( ( ret = mbedtls_mpi_write_file( "G = ", &G, 16, fout ) ) != 0 ) )
{
mbedtls_printf( " failed\n ! mbedtls_mpi_write_file returned %d\n\n", ret );
fclose( fout );
Expand Down

0 comments on commit 0fcc1cb

Please sign in to comment.