- Set sane start values for structures that are closed or freed.
This commit is contained in:
parent
896b3be1d1
commit
1a207ec8af
3 changed files with 24 additions and 9 deletions
|
@ -62,6 +62,7 @@ int main( void )
|
||||||
*/
|
*/
|
||||||
havege_init( &hs );
|
havege_init( &hs );
|
||||||
memset( &ssn, 0, sizeof( ssl_session ) );
|
memset( &ssn, 0, sizeof( ssl_session ) );
|
||||||
|
memset( &ssl, 0, sizeof( ssl_context ) );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1. Start the connection
|
* 1. Start the connection
|
||||||
|
|
|
@ -92,6 +92,16 @@ int main( int argc, char *argv[] )
|
||||||
int i, j, n;
|
int i, j, n;
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure memory references are valid.
|
||||||
|
*/
|
||||||
|
server_fd = 0;
|
||||||
|
memset( &ssn, 0, sizeof( ssl_session ) );
|
||||||
|
memset( &ssl, 0, sizeof( ssl_context ) );
|
||||||
|
memset( &cacert, 0, sizeof( x509_cert ) );
|
||||||
|
memset( &clicert, 0, sizeof( x509_cert ) );
|
||||||
|
memset( &rsa, 0, sizeof( rsa_context ) );
|
||||||
|
|
||||||
if( argc == 0 )
|
if( argc == 0 )
|
||||||
{
|
{
|
||||||
usage:
|
usage:
|
||||||
|
@ -149,7 +159,6 @@ int main( int argc, char *argv[] )
|
||||||
* 0. Initialize the RNG and the session data
|
* 0. Initialize the RNG and the session data
|
||||||
*/
|
*/
|
||||||
havege_init( &hs );
|
havege_init( &hs );
|
||||||
memset( &ssn, 0, sizeof( ssl_session ) );
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1.1. Load the trusted CA
|
* 1.1. Load the trusted CA
|
||||||
|
@ -157,8 +166,6 @@ int main( int argc, char *argv[] )
|
||||||
printf( "\n . Loading the CA root certificate ..." );
|
printf( "\n . Loading the CA root certificate ..." );
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
|
|
||||||
memset( &cacert, 0, sizeof( x509_cert ) );
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Alternatively, you may load the CA certificates from a .pem or
|
* Alternatively, you may load the CA certificates from a .pem or
|
||||||
* .crt file by calling x509parse_crtfile( &cacert, "myca.crt" ).
|
* .crt file by calling x509parse_crtfile( &cacert, "myca.crt" ).
|
||||||
|
@ -181,8 +188,6 @@ int main( int argc, char *argv[] )
|
||||||
printf( " . Loading the client cert. and key..." );
|
printf( " . Loading the client cert. and key..." );
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
|
|
||||||
memset( &clicert, 0, sizeof( x509_cert ) );
|
|
||||||
|
|
||||||
if( strlen( opt.crt_file ) )
|
if( strlen( opt.crt_file ) )
|
||||||
ret = x509parse_crtfile( &clicert, opt.crt_file );
|
ret = x509parse_crtfile( &clicert, opt.crt_file );
|
||||||
else
|
else
|
||||||
|
@ -357,7 +362,8 @@ int main( int argc, char *argv[] )
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
net_close( server_fd );
|
if( server_fd )
|
||||||
|
net_close( server_fd );
|
||||||
x509_free( &clicert );
|
x509_free( &clicert );
|
||||||
x509_free( &cacert );
|
x509_free( &cacert );
|
||||||
rsa_free( &rsa );
|
rsa_free( &rsa );
|
||||||
|
|
|
@ -89,6 +89,15 @@ int main( int argc, char *argv[] )
|
||||||
int i, j, n;
|
int i, j, n;
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set to sane values
|
||||||
|
*/
|
||||||
|
server_fd = 0;
|
||||||
|
memset( &ssl, 0, sizeof( ssl_context ) );
|
||||||
|
memset( &ssn, 0, sizeof( ssl_session ) );
|
||||||
|
memset( &clicert, 0, sizeof( x509_cert ) );
|
||||||
|
memset( &rsa, 0, sizeof( rsa_context ) );
|
||||||
|
|
||||||
if( argc == 0 )
|
if( argc == 0 )
|
||||||
{
|
{
|
||||||
usage:
|
usage:
|
||||||
|
@ -149,7 +158,6 @@ int main( int argc, char *argv[] )
|
||||||
if( opt.mode == MODE_FILE )
|
if( opt.mode == MODE_FILE )
|
||||||
{
|
{
|
||||||
x509_cert crt;
|
x509_cert crt;
|
||||||
|
|
||||||
memset( &crt, 0, sizeof( x509_cert ) );
|
memset( &crt, 0, sizeof( x509_cert ) );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -191,7 +199,6 @@ int main( int argc, char *argv[] )
|
||||||
* 1. Initialize the RNG and the session data
|
* 1. Initialize the RNG and the session data
|
||||||
*/
|
*/
|
||||||
havege_init( &hs );
|
havege_init( &hs );
|
||||||
memset( &ssn, 0, sizeof( ssl_session ) );
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 2. Start the connection
|
* 2. Start the connection
|
||||||
|
@ -265,7 +272,8 @@ int main( int argc, char *argv[] )
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
net_close( server_fd );
|
if( server_fd )
|
||||||
|
net_close( server_fd );
|
||||||
x509_free( &clicert );
|
x509_free( &clicert );
|
||||||
rsa_free( &rsa );
|
rsa_free( &rsa );
|
||||||
ssl_free( &ssl );
|
ssl_free( &ssl );
|
||||||
|
|
Loading…
Reference in a new issue