diff options
author | Adam Langley <agl@chromium.org> | 2014-09-02 14:28:49 -0700 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2014-09-02 22:39:41 +0000 |
commit | b2cb0ece7678586c9ca9c02dbc40069037b4f5a9 (patch) | |
tree | e1942774ab39d4d8437301e92e30f0041ff74ed5 | |
parent | ed8270a55c3845abbc85dfeed358597fef059ea9 (diff) | |
download | src-b2cb0ece7678586c9ca9c02dbc40069037b4f5a9.tar.gz |
Fix minor issues found by Clang's analysis.
Thanks to Denis Denisov for running the analysis.
Change-Id: I80810261e013423e746fd8d8afefb3581cffccc0
Reviewed-on: https://boringssl-review.googlesource.com/1701
Reviewed-by: Adam Langley <agl@google.com>
-rw-r--r-- | crypto/bio/bio_mem.c | 7 | ||||
-rw-r--r-- | crypto/ec/wnaf.c | 2 | ||||
-rw-r--r-- | crypto/ecdsa/ecdsa.c | 5 | ||||
-rw-r--r-- | crypto/evp/example_sign.c | 8 | ||||
-rw-r--r-- | crypto/internal.h | 4 | ||||
-rw-r--r-- | include/openssl/base.h | 9 | ||||
-rw-r--r-- | ssl/d1_both.c | 1 | ||||
-rw-r--r-- | ssl/s3_clnt.c | 5 | ||||
-rw-r--r-- | ssl/ssl_lib.c | 2 |
9 files changed, 28 insertions, 15 deletions
diff --git a/crypto/bio/bio_mem.c b/crypto/bio/bio_mem.c index 457c2e0..6e90db5 100644 --- a/crypto/bio/bio_mem.c +++ b/crypto/bio/bio_mem.c @@ -132,13 +132,12 @@ static int mem_free(BIO *bio) { } static int mem_read(BIO *bio, char *out, int outl) { - int ret = -1; - BUF_MEM *b; + int ret; + BUF_MEM *b = (BUF_MEM*) bio->ptr; - b = (BUF_MEM *)bio->ptr; BIO_clear_retry_flags(bio); ret = outl; - if (ret > (int)b->length) { + if (b->length < INT_MAX && ret > (int)b->length) { ret = b->length; } diff --git a/crypto/ec/wnaf.c b/crypto/ec/wnaf.c index b86107d..2fed4a5 100644 --- a/crypto/ec/wnaf.c +++ b/crypto/ec/wnaf.c @@ -448,8 +448,6 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, wNAF[num] = tmp_wNAF; wNAF[num + 1] = NULL; wNAF_len[num] = tmp_len; - if (tmp_len > max_len) - max_len = tmp_len; /* pre_comp->points starts with the points that we need here: */ val_sub[num] = pre_comp->points; } else { diff --git a/crypto/ecdsa/ecdsa.c b/crypto/ecdsa/ecdsa.c index 067fd6c..ddc3e61 100644 --- a/crypto/ecdsa/ecdsa.c +++ b/crypto/ecdsa/ecdsa.c @@ -140,8 +140,9 @@ int ECDSA_do_verify(const uint8_t *digest, size_t digest_len, } /* check input values */ - if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL || - (pub_key = EC_KEY_get0_public_key(eckey)) == NULL || sig == NULL) { + if ((group = EC_KEY_get0_group(eckey)) == NULL || + (pub_key = EC_KEY_get0_public_key(eckey)) == NULL || + sig == NULL) { OPENSSL_PUT_ERROR(ECDSA, ECDSA_do_verify, ECDSA_R_MISSING_PARAMETERS); return 0; } diff --git a/crypto/evp/example_sign.c b/crypto/evp/example_sign.c index 847330d..9d2a296 100644 --- a/crypto/evp/example_sign.c +++ b/crypto/evp/example_sign.c @@ -127,9 +127,13 @@ int example_EVP_DigestSignInit(void) { fprintf(stderr, "sig_len mismatch\n"); goto out; } + sig = malloc(sig_len); - if (sig == NULL || - EVP_DigestSignFinal(&md_ctx, sig, &sig_len) != 1) { + if (sig == NULL) { + goto out; + } + if (EVP_DigestSignFinal(&md_ctx, sig, &sig_len) != 1) { + free(sig); goto out; } diff --git a/crypto/internal.h b/crypto/internal.h index 39d35ad..65a52ed 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -111,6 +111,10 @@ #include <openssl/ex_data.h> +#if defined(__cplusplus) +extern "C" { +#endif + /* st_CRYPTO_EX_DATA_IMPL contains an ex_data implementation. See the comments * in ex_data.h for details of the behaviour of each of the functions. */ diff --git a/include/openssl/base.h b/include/openssl/base.h index bee4030..079b1c4 100644 --- a/include/openssl/base.h +++ b/include/openssl/base.h @@ -63,6 +63,11 @@ #include <openssl/opensslfeatures.h> +#if defined(__cplusplus) +extern "C" { +#endif + + #if defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) #define OPENSSL_64_BIT #define OPENSSL_X86_64 @@ -205,4 +210,8 @@ typedef struct x509_store_st X509_STORE; typedef void *OPENSSL_BLOCK; +#if defined(__cplusplus) +} /* extern C */ +#endif + #endif /* OPENSSL_HEADER_BASE_H */ diff --git a/ssl/d1_both.c b/ssl/d1_both.c index caa18d1..2d944d8 100644 --- a/ssl/d1_both.c +++ b/ssl/d1_both.c @@ -1165,7 +1165,6 @@ dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off, saved_state.write_hash = s->write_hash; saved_state.session = s->session; saved_state.epoch = s->d1->w_epoch; - saved_state.epoch = s->d1->w_epoch; s->d1->retransmitting = 1; diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c index 44d26a7..97d1107 100644 --- a/ssl/s3_clnt.c +++ b/ssl/s3_clnt.c @@ -2229,9 +2229,8 @@ int ssl3_send_client_key_exchange(SSL *s) /* Free allocated memory */ BN_CTX_free(bn_ctx); - if (encodedPoint != NULL) OPENSSL_free(encodedPoint); - if (clnt_ecdh != NULL) - EC_KEY_free(clnt_ecdh); + OPENSSL_free(encodedPoint); + EC_KEY_free(clnt_ecdh); EVP_PKEY_free(srvr_pub_pkey); } else if (!(alg_k & SSL_kPSK) || ((alg_k & SSL_kPSK) && !(alg_a & SSL_aPSK))) diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 58684b0..b8df1bf 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -1079,7 +1079,7 @@ int SSL_shutdown(SSL *s) return -1; } - if ((s != NULL) && !SSL_in_init(s)) + if (!SSL_in_init(s)) return(s->method->ssl_shutdown(s)); else return(1); |