From 583b608401097b0c7785ba3328c9451ed9921964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 20 Aug 2013 16:58:13 +0200 Subject: [PATCH] Fix some return values --- library/pk_wrap.c | 4 ++-- library/ssl_cli.c | 10 ++++++---- library/ssl_srv.c | 11 +++++++---- library/x509parse.c | 5 +++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/library/pk_wrap.c b/library/pk_wrap.c index c2a4c7fce..249f7bd0c 100644 --- a/library/pk_wrap.c +++ b/library/pk_wrap.c @@ -141,8 +141,8 @@ static int eckey_verify_wrap( void *ctx, md_type_t md_alg, ecdsa_init( &ecdsa ); - ret = ecdsa_from_keypair( &ecdsa, ctx ) || - ecdsa_verify_wrap( &ecdsa, md_alg, hash, hash_len, sig, sig_len ); + if( ( ret = ecdsa_from_keypair( &ecdsa, ctx ) ) == 0 ) + ret = ecdsa_verify_wrap( &ecdsa, md_alg, hash, hash_len, sig, sig_len ); ecdsa_free( &ecdsa ); diff --git a/library/ssl_cli.c b/library/ssl_cli.c index dbc804afa..274cb3ae3 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -2066,10 +2066,12 @@ static int ssl_write_certificate_verify( ssl_context *ssl ) ecdsa_init( &ecdsa ); - ret = ecdsa_from_keypair( &ecdsa, ssl->pk_key->pk_ctx ) || - ecdsa_write_signature( &ecdsa, hash, hashlen, - ssl->out_msg + 6 + offset, &n, - ssl->f_rng, ssl->p_rng ); + if( ( ret = ecdsa_from_keypair( &ecdsa, ssl->pk_key->pk_ctx ) ) == 0 ) + { + ret = ecdsa_write_signature( &ecdsa, hash, hashlen, + ssl->out_msg + 6 + offset, &n, + ssl->f_rng, ssl->p_rng ); + } ecdsa_free( &ecdsa ); diff --git a/library/ssl_srv.c b/library/ssl_srv.c index f8e174845..e3f604fe9 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -2106,10 +2106,13 @@ static int ssl_write_server_key_exchange( ssl_context *ssl ) ecdsa_init( &ecdsa ); - ret = ecdsa_from_keypair( &ecdsa, ssl->pk_key->pk_ctx ) || - ecdsa_write_signature( &ecdsa, hash, hashlen, - p + 2, &signature_len, - ssl->f_rng, ssl->p_rng ); + ret = ecdsa_from_keypair( &ecdsa, ssl->pk_key->pk_ctx ); + if( ret == 0 ) + { + ret = ecdsa_write_signature( &ecdsa, hash, hashlen, + p + 2, &signature_len, + ssl->f_rng, ssl->p_rng ); + } ecdsa_free( &ecdsa ); diff --git a/library/x509parse.c b/library/x509parse.c index a76285512..9f90b5ab6 100644 --- a/library/x509parse.c +++ b/library/x509parse.c @@ -605,8 +605,9 @@ static int x509_get_pubkey( unsigned char **p, #if defined(POLARSSL_ECP_C) if( pk_alg == POLARSSL_PK_ECKEY_DH || pk_alg == POLARSSL_PK_ECKEY ) { - ret = x509_use_ecparams( &alg_params, &pk_ec( *pk )->grp ) || - x509_get_ecpubkey( p, end, pk_ec( *pk ) ); + ret = x509_use_ecparams( &alg_params, &pk_ec( *pk )->grp ); + if( ret == 0 ) + ret = x509_get_ecpubkey( p, end, pk_ec( *pk ) ); } else #endif /* POLARSSL_ECP_C */ ret = POLARSSL_ERR_X509_UNKNOWN_PK_ALG;