[openssl-commits] [openssl] master update
Rich Salz
rsalz at openssl.org
Fri Dec 8 16:11:06 UTC 2017
The branch master has been updated
via a0fda2cf2dac8bc0d309261b3aaf4027a188b08c (commit)
from cef115ff0ca4255d3decc1dda87c5418a961fd2c (commit)
- Log -----------------------------------------------------------------
commit a0fda2cf2dac8bc0d309261b3aaf4027a188b08c
Author: FdaSilvaYY <fdasilvayy at gmail.com>
Date: Fri Dec 8 10:49:41 2017 -0500
Address some code-analysis issues.
Expression '...' is always true.
The 'b->init' variable is assigned values twice successively
Reviewed-by: Kurt Roeckx <kurt at roeckx.be>
Reviewed-by: Rich Salz <rsalz at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4753)
-----------------------------------------------------------------------
Summary of changes:
crypto/asn1/x_algor.c | 11 ++++++-----
crypto/bio/bss_acpt.c | 1 -
crypto/bio/bss_mem.c | 28 ++++++++++++----------------
crypto/ec/ec2_smpl.c | 10 ++++------
crypto/err/err.c | 8 +++-----
crypto/store/loader_file.c | 4 ++--
6 files changed, 27 insertions(+), 35 deletions(-)
diff --git a/crypto/asn1/x_algor.c b/crypto/asn1/x_algor.c
index 72378db..853d45b 100644
--- a/crypto/asn1/x_algor.c
+++ b/crypto/asn1/x_algor.c
@@ -28,18 +28,19 @@ IMPLEMENT_ASN1_DUP_FUNCTION(X509_ALGOR)
int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval)
{
- if (!alg)
+ if (alg == NULL)
return 0;
+
if (ptype != V_ASN1_UNDEF) {
if (alg->parameter == NULL)
alg->parameter = ASN1_TYPE_new();
if (alg->parameter == NULL)
return 0;
}
- if (alg) {
- ASN1_OBJECT_free(alg->algorithm);
- alg->algorithm = aobj;
- }
+
+ ASN1_OBJECT_free(alg->algorithm);
+ alg->algorithm = aobj;
+
if (ptype == 0)
return 1;
if (ptype == V_ASN1_UNDEF) {
diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c
index f795b89..e49c7ce 100644
--- a/crypto/bio/bss_acpt.c
+++ b/crypto/bio/bss_acpt.c
@@ -450,7 +450,6 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
data->accepted_mode &= ~BIO_SOCK_NONBLOCK;
break;
case BIO_C_SET_FD:
- b->init = 1;
b->num = *((int *)ptr);
data->accept_sock = b->num;
data->state = ACPT_S_ACCEPT;
diff --git a/crypto/bio/bss_mem.c b/crypto/bio/bss_mem.c
index 6214725..a50d416 100644
--- a/crypto/bio/bss_mem.c
+++ b/crypto/bio/bss_mem.c
@@ -147,23 +147,19 @@ static int mem_buf_free(BIO *a, int free_all)
{
if (a == NULL)
return 0;
- if (a->shutdown) {
- if ((a->init) && (a->ptr != NULL)) {
- BUF_MEM *b;
- BIO_BUF_MEM *bb = (BIO_BUF_MEM *)a->ptr;
-
- if (bb != NULL) {
- b = bb->buf;
- if (a->flags & BIO_FLAGS_MEM_RDONLY)
- b->data = NULL;
- BUF_MEM_free(b);
- if (free_all) {
- OPENSSL_free(bb->readp);
- OPENSSL_free(bb);
- }
- }
- a->ptr = NULL;
+
+ if (a->shutdown && a->init && a->ptr != NULL) {
+ BIO_BUF_MEM *bb = (BIO_BUF_MEM *)a->ptr;
+ BUF_MEM *b = bb->buf;
+
+ if (a->flags & BIO_FLAGS_MEM_RDONLY)
+ b->data = NULL;
+ BUF_MEM_free(b);
+ if (free_all) {
+ OPENSSL_free(bb->readp);
+ OPENSSL_free(bb);
}
+ a->ptr = NULL;
}
return 1;
}
diff --git a/crypto/ec/ec2_smpl.c b/crypto/ec/ec2_smpl.c
index 08e4592..6bd5f9d 100644
--- a/crypto/ec/ec2_smpl.c
+++ b/crypto/ec/ec2_smpl.c
@@ -603,9 +603,9 @@ int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point,
if (!BN_GF2m_add(lh, lh, y2))
goto err;
ret = BN_is_zero(lh);
+
err:
- if (ctx)
- BN_CTX_end(ctx);
+ BN_CTX_end(ctx);
BN_CTX_free(new_ctx);
return ret;
}
@@ -656,8 +656,7 @@ int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a,
ret = ((BN_cmp(aX, bX) == 0) && BN_cmp(aY, bY) == 0) ? 0 : 1;
err:
- if (ctx)
- BN_CTX_end(ctx);
+ BN_CTX_end(ctx);
BN_CTX_free(new_ctx);
return ret;
}
@@ -698,8 +697,7 @@ int ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point,
ret = 1;
err:
- if (ctx)
- BN_CTX_end(ctx);
+ BN_CTX_end(ctx);
BN_CTX_free(new_ctx);
return ret;
}
diff --git a/crypto/err/err.c b/crypto/err/err.c
index 75dc715..bd9e062 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -502,15 +502,13 @@ static unsigned long get_error_values(int inc, int top, const char **file,
es->err_buffer[i] = 0;
}
- if ((file != NULL) && (line != NULL)) {
+ if (file != NULL && line != NULL) {
if (es->err_file[i] == NULL) {
*file = "NA";
- if (line != NULL)
- *line = 0;
+ *line = 0;
} else {
*file = es->err_file[i];
- if (line != NULL)
- *line = es->err_line[i];
+ *line = es->err_line[i];
}
}
diff --git a/crypto/store/loader_file.c b/crypto/store/loader_file.c
index 00d0302..588a581 100644
--- a/crypto/store/loader_file.c
+++ b/crypto/store/loader_file.c
@@ -962,8 +962,8 @@ static OSSL_STORE_INFO *file_load_try_decode(OSSL_STORE_LOADER_CTX *ctx,
ui_method, ui_data);
if (try_matchcount > 0) {
- if (matching_handlers)
- matching_handlers[*matchcount] = handler;
+
+ matching_handlers[*matchcount] = handler;
if (handler_ctx)
handler->destroy_ctx(&handler_ctx);
More information about the openssl-commits
mailing list