diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2014-07-12 16:03:38 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2014-07-12 16:03:38 +0000 |
commit | 9b9c3798fe5e8ea04f651f773d84a8b6556e785b (patch) | |
tree | d00ca31c47fb61298dff542831203c3643f089d0 /lib | |
parent | 7dbb741c19a6a70ae676e79e9a5ca1055411a3cb (diff) |
if (x) FOO_free(x) -> FOO_free(x).
Improves readability, keeps the code smaller so that it is warmer in your
cache.
review & ok deraadt@
Diffstat (limited to 'lib')
64 files changed, 319 insertions, 549 deletions
diff --git a/lib/libssl/src/crypto/asn1/a_object.c b/lib/libssl/src/crypto/asn1/a_object.c index 551aece6ad8..863aa6a226a 100644 --- a/lib/libssl/src/crypto/asn1/a_object.c +++ b/lib/libssl/src/crypto/asn1/a_object.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_object.c,v 1.21 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: a_object.c,v 1.22 2014/07/12 16:03:36 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -206,15 +206,13 @@ a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num) } if (tmp != ftmp) free(tmp); - if (bl) - BN_free(bl); + BN_free(bl); return (len); err: if (tmp != ftmp) free(tmp); - if (bl) - BN_free(bl); + BN_free(bl); return (0); } diff --git a/lib/libssl/src/crypto/asn1/asn1_par.c b/lib/libssl/src/crypto/asn1/asn1_par.c index c6f95c42aba..f5e3a8b5297 100644 --- a/lib/libssl/src/crypto/asn1/asn1_par.c +++ b/lib/libssl/src/crypto/asn1/asn1_par.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_par.c,v 1.19 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: asn1_par.c,v 1.20 2014/07/12 16:03:36 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -291,10 +291,8 @@ asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offset, nl = 1; } } - if (os != NULL) { - M_ASN1_OCTET_STRING_free(os); - os = NULL; - } + M_ASN1_OCTET_STRING_free(os); + os = NULL; } else if (tag == V_ASN1_INTEGER) { ASN1_INTEGER *bs; int i; @@ -376,8 +374,7 @@ asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offset, end: if (o != NULL) ASN1_OBJECT_free(o); - if (os != NULL) - M_ASN1_OCTET_STRING_free(os); + M_ASN1_OCTET_STRING_free(os); *pp = p; return (ret); } diff --git a/lib/libssl/src/crypto/asn1/evp_asn1.c b/lib/libssl/src/crypto/asn1/evp_asn1.c index 199c12f9a40..5e21f3c8ae4 100644 --- a/lib/libssl/src/crypto/asn1/evp_asn1.c +++ b/lib/libssl/src/crypto/asn1/evp_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_asn1.c,v 1.12 2014/07/11 13:41:59 miod Exp $ */ +/* $OpenBSD: evp_asn1.c,v 1.13 2014/07/12 16:03:36 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -193,9 +193,7 @@ err: ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING, ASN1_R_DATA_IS_WRONG); } - if (os != NULL) - M_ASN1_OCTET_STRING_free(os); - if (ai != NULL) - M_ASN1_INTEGER_free(ai); + M_ASN1_OCTET_STRING_free(os); + M_ASN1_INTEGER_free(ai); return (ret); } diff --git a/lib/libssl/src/crypto/asn1/x_pkey.c b/lib/libssl/src/crypto/asn1/x_pkey.c index a5134bc6a2a..d454afb72bb 100644 --- a/lib/libssl/src/crypto/asn1/x_pkey.c +++ b/lib/libssl/src/crypto/asn1/x_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_pkey.c,v 1.14 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: x_pkey.c,v 1.15 2014/07/12 16:03:36 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -149,10 +149,8 @@ X509_PKEY_free(X509_PKEY *x) if (x->enc_algor != NULL) X509_ALGOR_free(x->enc_algor); - if (x->enc_pkey != NULL) - M_ASN1_OCTET_STRING_free(x->enc_pkey); - if (x->dec_pkey != NULL) - EVP_PKEY_free(x->dec_pkey); + M_ASN1_OCTET_STRING_free(x->enc_pkey); + EVP_PKEY_free(x->dec_pkey); if ((x->key_data != NULL) && (x->key_free)) free(x->key_data); free(x); diff --git a/lib/libssl/src/crypto/asn1/x_pubkey.c b/lib/libssl/src/crypto/asn1/x_pubkey.c index 87cb25bb507..56cc63059a7 100644 --- a/lib/libssl/src/crypto/asn1/x_pubkey.c +++ b/lib/libssl/src/crypto/asn1/x_pubkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_pubkey.c,v 1.21 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: x_pubkey.c,v 1.22 2014/07/12 16:03:36 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -183,8 +183,7 @@ X509_PUBKEY_get(X509_PUBKEY *key) return ret; error: - if (ret != NULL) - EVP_PKEY_free(ret); + EVP_PKEY_free(ret); return (NULL); } diff --git a/lib/libssl/src/crypto/bn/bn_blind.c b/lib/libssl/src/crypto/bn/bn_blind.c index 5f559da0677..c842f76c6ff 100644 --- a/lib/libssl/src/crypto/bn/bn_blind.c +++ b/lib/libssl/src/crypto/bn/bn_blind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_blind.c,v 1.13 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: bn_blind.c,v 1.14 2014/07/12 16:03:36 miod Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * @@ -181,14 +181,10 @@ BN_BLINDING_free(BN_BLINDING *r) if (r == NULL) return; - if (r->A != NULL) - BN_clear_free(r->A ); - if (r->Ai != NULL) - BN_clear_free(r->Ai); - if (r->e != NULL) - BN_clear_free(r->e ); - if (r->mod != NULL) - BN_clear_free(r->mod); + BN_clear_free(r->A); + BN_clear_free(r->Ai); + BN_clear_free(r->e); + BN_clear_free(r->mod); free(r); } @@ -341,8 +337,7 @@ BN_BLINDING_create_param(BN_BLINDING *b, const BIGNUM *e, BIGNUM *m, goto err; if (e != NULL) { - if (ret->e != NULL) - BN_free(ret->e); + BN_free(ret->e); ret->e = BN_dup(e); } if (ret->e == NULL) diff --git a/lib/libssl/src/crypto/bn/bn_lib.c b/lib/libssl/src/crypto/bn/bn_lib.c index 4ee9b2bbdec..d0cb49cd1e7 100644 --- a/lib/libssl/src/crypto/bn/bn_lib.c +++ b/lib/libssl/src/crypto/bn/bn_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_lib.c,v 1.32 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: bn_lib.c,v 1.33 2014/07/12 16:03:36 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -585,8 +585,7 @@ BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret) i = ((n - 1) / BN_BYTES) + 1; m = ((n - 1) % (BN_BYTES)); if (bn_wexpand(ret, (int)i) == NULL) { - if (bn) - BN_free(bn); + BN_free(bn); return NULL; } ret->top = i; diff --git a/lib/libssl/src/crypto/bn/bn_mod.c b/lib/libssl/src/crypto/bn/bn_mod.c index a503ff3b1be..67bd3541b0c 100644 --- a/lib/libssl/src/crypto/bn/bn_mod.c +++ b/lib/libssl/src/crypto/bn/bn_mod.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mod.c,v 1.8 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: bn_mod.c,v 1.9 2014/07/12 16:03:36 miod Exp $ */ /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> * for the OpenSSL project. */ /* ==================================================================== @@ -253,8 +253,7 @@ BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx) ret = BN_mod_lshift_quick(r, r, n, (abs_m ? abs_m : m)); bn_check_top(r); - if (abs_m) - BN_free(abs_m); + BN_free(abs_m); return ret; } diff --git a/lib/libssl/src/crypto/bn/bn_prime.c b/lib/libssl/src/crypto/bn/bn_prime.c index db786a63ef0..27468ceb936 100644 --- a/lib/libssl/src/crypto/bn/bn_prime.c +++ b/lib/libssl/src/crypto/bn/bn_prime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_prime.c,v 1.10 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: bn_prime.c,v 1.11 2014/07/12 16:03:36 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -344,8 +344,7 @@ err: if (ctx_passed == NULL) BN_CTX_free(ctx); } - if (mont != NULL) - BN_MONT_CTX_free(mont); + BN_MONT_CTX_free(mont); return (ret); } diff --git a/lib/libssl/src/crypto/bn/bn_print.c b/lib/libssl/src/crypto/bn/bn_print.c index ccdae5ae092..4920705a5b7 100644 --- a/lib/libssl/src/crypto/bn/bn_print.c +++ b/lib/libssl/src/crypto/bn/bn_print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_print.c,v 1.22 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: bn_print.c,v 1.23 2014/07/12 16:03:36 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -163,8 +163,7 @@ BN_bn2dec(const BIGNUM *a) err: free(bn_data); - if (t != NULL) - BN_free(t); + BN_free(t); if (!ok && buf) { free(buf); buf = NULL; diff --git a/lib/libssl/src/crypto/cmac/cm_ameth.c b/lib/libssl/src/crypto/cmac/cm_ameth.c index 39d8ad3aa8f..e7e7fe0f804 100644 --- a/lib/libssl/src/crypto/cmac/cm_ameth.c +++ b/lib/libssl/src/crypto/cmac/cm_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cm_ameth.c,v 1.6 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: cm_ameth.c,v 1.7 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2010. */ @@ -74,8 +74,7 @@ cmac_key_free(EVP_PKEY *pkey) { CMAC_CTX *cmctx = (CMAC_CTX *)pkey->pkey.ptr; - if (cmctx) - CMAC_CTX_free(cmctx); + CMAC_CTX_free(cmctx); } const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = { diff --git a/lib/libssl/src/crypto/cms/cms_asn1.c b/lib/libssl/src/crypto/cms/cms_asn1.c index a75fa26137a..fbdac5b1ba1 100644 --- a/lib/libssl/src/crypto/cms/cms_asn1.c +++ b/lib/libssl/src/crypto/cms/cms_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_asn1.c,v 1.4 2014/06/12 15:49:28 deraadt Exp $ */ +/* $OpenBSD: cms_asn1.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -91,8 +91,7 @@ cms_si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { if (operation == ASN1_OP_FREE_POST) { CMS_SignerInfo *si = (CMS_SignerInfo *)*pval; - if (si->pkey) - EVP_PKEY_free(si->pkey); + EVP_PKEY_free(si->pkey); if (si->signer) X509_free(si->signer); } @@ -219,8 +218,7 @@ cms_ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) CMS_RecipientInfo *ri = (CMS_RecipientInfo *)*pval; if (ri->type == CMS_RECIPINFO_TRANS) { CMS_KeyTransRecipientInfo *ktri = ri->d.ktri; - if (ktri->pkey) - EVP_PKEY_free(ktri->pkey); + EVP_PKEY_free(ktri->pkey); if (ktri->recip) X509_free(ktri->recip); } else if (ri->type == CMS_RECIPINFO_KEK) { diff --git a/lib/libssl/src/crypto/cms/cms_env.c b/lib/libssl/src/crypto/cms/cms_env.c index 66ec1a93432..19c86b95505 100644 --- a/lib/libssl/src/crypto/cms/cms_env.c +++ b/lib/libssl/src/crypto/cms/cms_env.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_env.c,v 1.6 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: cms_env.c,v 1.7 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -346,8 +346,7 @@ cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) ret = 1; err: - if (pctx) - EVP_PKEY_CTX_free(pctx); + EVP_PKEY_CTX_free(pctx); free(ek); return ret; } @@ -416,8 +415,7 @@ cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) ec->keylen = eklen; err: - if (pctx) - EVP_PKEY_CTX_free(pctx); + EVP_PKEY_CTX_free(pctx); if (!ret && ek) free(ek); diff --git a/lib/libssl/src/crypto/cms/cms_sd.c b/lib/libssl/src/crypto/cms/cms_sd.c index 7e490c09886..70ad897bda5 100644 --- a/lib/libssl/src/crypto/cms/cms_sd.c +++ b/lib/libssl/src/crypto/cms/cms_sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_sd.c,v 1.7 2014/07/11 13:02:10 miod Exp $ */ +/* $OpenBSD: cms_sd.c,v 1.8 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -495,8 +495,7 @@ CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer) { if (signer) { CRYPTO_add(&signer->references, 1, CRYPTO_LOCK_X509); - if (si->pkey) - EVP_PKEY_free(si->pkey); + EVP_PKEY_free(si->pkey); si->pkey = X509_get_pubkey(signer); } if (si->signer) diff --git a/lib/libssl/src/crypto/dh/dh_ameth.c b/lib/libssl/src/crypto/dh/dh_ameth.c index 91178a92b0c..729c996a1b5 100644 --- a/lib/libssl/src/crypto/dh/dh_ameth.c +++ b/lib/libssl/src/crypto/dh/dh_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_ameth.c,v 1.11 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: dh_ameth.c,v 1.12 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -120,8 +120,7 @@ dh_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) err: if (public_key) ASN1_INTEGER_free(public_key); - if (dh) - DH_free(dh); + DH_free(dh); return 0; } @@ -409,14 +408,12 @@ dh_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) if ((a = BN_dup(from->pkey.dh->p)) == NULL) return 0; - if (to->pkey.dh->p != NULL) - BN_free(to->pkey.dh->p); + BN_free(to->pkey.dh->p); to->pkey.dh->p = a; if ((a = BN_dup(from->pkey.dh->g)) == NULL) return 0; - if (to->pkey.dh->g != NULL) - BN_free(to->pkey.dh->g); + BN_free(to->pkey.dh->g); to->pkey.dh->g = a; return 1; diff --git a/lib/libssl/src/crypto/dh/dh_check.c b/lib/libssl/src/crypto/dh/dh_check.c index 01b9531a442..0f6c50b055d 100644 --- a/lib/libssl/src/crypto/dh/dh_check.c +++ b/lib/libssl/src/crypto/dh/dh_check.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_check.c,v 1.13 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: dh_check.c,v 1.14 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -114,10 +114,8 @@ DH_check(const DH *dh, int *ret) } ok = 1; err: - if (ctx != NULL) - BN_CTX_free(ctx); - if (q != NULL) - BN_free(q); + BN_CTX_free(ctx); + BN_free(q); return ok; } diff --git a/lib/libssl/src/crypto/dh/dh_key.c b/lib/libssl/src/crypto/dh/dh_key.c index 6d908161228..132ba5cfa42 100644 --- a/lib/libssl/src/crypto/dh/dh_key.c +++ b/lib/libssl/src/crypto/dh/dh_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_key.c,v 1.20 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: dh_key.c,v 1.21 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -260,7 +260,6 @@ dh_init(DH *dh) static int dh_finish(DH *dh) { - if (dh->method_mont_p) - BN_MONT_CTX_free(dh->method_mont_p); + BN_MONT_CTX_free(dh->method_mont_p); return 1; } diff --git a/lib/libssl/src/crypto/dh/dh_lib.c b/lib/libssl/src/crypto/dh/dh_lib.c index 0a956e5416f..c438f387c01 100644 --- a/lib/libssl/src/crypto/dh/dh_lib.c +++ b/lib/libssl/src/crypto/dh/dh_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_lib.c,v 1.19 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: dh_lib.c,v 1.20 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -194,21 +194,14 @@ DH_free(DH *r) CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data); - if (r->p != NULL) - BN_clear_free(r->p); - if (r->g != NULL) - BN_clear_free(r->g); - if (r->q != NULL) - BN_clear_free(r->q); - if (r->j != NULL) - BN_clear_free(r->j); + BN_clear_free(r->p); + BN_clear_free(r->g); + BN_clear_free(r->q); + BN_clear_free(r->j); free(r->seed); - if (r->counter != NULL) - BN_clear_free(r->counter); - if (r->pub_key != NULL) - BN_clear_free(r->pub_key); - if (r->priv_key != NULL) - BN_clear_free(r->priv_key); + BN_clear_free(r->counter); + BN_clear_free(r->pub_key); + BN_clear_free(r->priv_key); free(r); } diff --git a/lib/libssl/src/crypto/dsa/dsa.h b/lib/libssl/src/crypto/dsa/dsa.h index c1264ac325f..bd7b26070d9 100644 --- a/lib/libssl/src/crypto/dsa/dsa.h +++ b/lib/libssl/src/crypto/dsa/dsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa.h,v 1.17 2014/06/12 15:49:28 deraadt Exp $ */ +/* $OpenBSD: dsa.h,v 1.18 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -206,7 +206,7 @@ int DSA_set_method(DSA *dsa, const DSA_METHOD *); DSA * DSA_new(void); DSA * DSA_new_method(ENGINE *engine); -void DSA_free (DSA *r); +void DSA_free(DSA *r); /* "up" the DSA object's reference count */ int DSA_up_ref(DSA *r); int DSA_size(const DSA *); diff --git a/lib/libssl/src/crypto/dsa/dsa_ameth.c b/lib/libssl/src/crypto/dsa/dsa_ameth.c index 73c58ec94c9..7da4ac5695a 100644 --- a/lib/libssl/src/crypto/dsa/dsa_ameth.c +++ b/lib/libssl/src/crypto/dsa/dsa_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_ameth.c,v 1.12 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: dsa_ameth.c,v 1.13 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -125,8 +125,7 @@ dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) err: if (public_key) ASN1_INTEGER_free(public_key); - if (dsa) - DSA_free(dsa); + DSA_free(dsa); return 0; } @@ -264,7 +263,7 @@ dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) } EVP_PKEY_assign_DSA(pkey, dsa); - BN_CTX_free (ctx); + BN_CTX_free(ctx); if (ndsa) sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); else @@ -275,7 +274,7 @@ dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) decerr: DSAerr(DSA_F_DSA_PRIV_DECODE, EVP_R_DECODE_ERROR); dsaerr: - BN_CTX_free (ctx); + BN_CTX_free(ctx); if (privkey) ASN1_INTEGER_free(privkey); sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); @@ -358,20 +357,17 @@ dsa_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) if ((a = BN_dup(from->pkey.dsa->p)) == NULL) return 0; - if (to->pkey.dsa->p != NULL) - BN_free(to->pkey.dsa->p); + BN_free(to->pkey.dsa->p); to->pkey.dsa->p = a; if ((a = BN_dup(from->pkey.dsa->q)) == NULL) return 0; - if (to->pkey.dsa->q != NULL) - BN_free(to->pkey.dsa->q); + BN_free(to->pkey.dsa->q); to->pkey.dsa->q = a; if ((a = BN_dup(from->pkey.dsa->g)) == NULL) return 0; - if (to->pkey.dsa->g != NULL) - BN_free(to->pkey.dsa->g); + BN_free(to->pkey.dsa->g); to->pkey.dsa->g = a; return 1; } diff --git a/lib/libssl/src/crypto/dsa/dsa_gen.c b/lib/libssl/src/crypto/dsa/dsa_gen.c index d41e7562e10..a3d07b901a6 100644 --- a/lib/libssl/src/crypto/dsa/dsa_gen.c +++ b/lib/libssl/src/crypto/dsa/dsa_gen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_gen.c,v 1.15 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: dsa_gen.c,v 1.16 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -322,12 +322,9 @@ end: ok = 1; err: if (ok) { - if (ret->p) - BN_free(ret->p); - if (ret->q) - BN_free(ret->q); - if (ret->g) - BN_free(ret->g); + BN_free(ret->p); + BN_free(ret->q); + BN_free(ret->g); ret->p = BN_dup(p); ret->q = BN_dup(q); ret->g = BN_dup(g); @@ -346,8 +343,7 @@ err: BN_CTX_end(ctx); BN_CTX_free(ctx); } - if (mont != NULL) - BN_MONT_CTX_free(mont); + BN_MONT_CTX_free(mont); return ok; } #endif diff --git a/lib/libssl/src/crypto/dsa/dsa_key.c b/lib/libssl/src/crypto/dsa/dsa_key.c index 4573ecbccea..4dc28dbb90c 100644 --- a/lib/libssl/src/crypto/dsa/dsa_key.c +++ b/lib/libssl/src/crypto/dsa/dsa_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_key.c,v 1.18 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: dsa_key.c,v 1.19 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -128,8 +128,7 @@ err: BN_free(pub_key); if (priv_key != NULL && dsa->priv_key == NULL) BN_free(priv_key); - if (ctx != NULL) - BN_CTX_free(ctx); + BN_CTX_free(ctx); return ok; } #endif diff --git a/lib/libssl/src/crypto/dsa/dsa_lib.c b/lib/libssl/src/crypto/dsa/dsa_lib.c index 97307134cd5..1cfd6ce6b83 100644 --- a/lib/libssl/src/crypto/dsa/dsa_lib.c +++ b/lib/libssl/src/crypto/dsa/dsa_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_lib.c,v 1.20 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: dsa_lib.c,v 1.21 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -201,20 +201,13 @@ DSA_free(DSA *r) CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); - if (r->p != NULL) - BN_clear_free(r->p); - if (r->q != NULL) - BN_clear_free(r->q); - if (r->g != NULL) - BN_clear_free(r->g); - if (r->pub_key != NULL) - BN_clear_free(r->pub_key); - if (r->priv_key != NULL) - BN_clear_free(r->priv_key); - if (r->kinv != NULL) - BN_clear_free(r->kinv); - if (r->r != NULL) - BN_clear_free(r->r); + BN_clear_free(r->p); + BN_clear_free(r->q); + BN_clear_free(r->g); + BN_clear_free(r->pub_key); + BN_clear_free(r->priv_key); + BN_clear_free(r->kinv); + BN_clear_free(r->r); free(r); } @@ -305,8 +298,7 @@ DSA_dup_DH(const DSA *r) return ret; err: - if (ret != NULL) - DH_free(ret); + DH_free(ret); return NULL; } #endif diff --git a/lib/libssl/src/crypto/dsa/dsa_ossl.c b/lib/libssl/src/crypto/dsa/dsa_ossl.c index 5bff836c500..e3728530634 100644 --- a/lib/libssl/src/crypto/dsa/dsa_ossl.c +++ b/lib/libssl/src/crypto/dsa/dsa_ossl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_ossl.c,v 1.20 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: dsa_ossl.c,v 1.21 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -212,12 +212,10 @@ err: BN_free(r); BN_free(s); } - if (ctx != NULL) - BN_CTX_free(ctx); + BN_CTX_free(ctx); BN_clear_free(&m); BN_clear_free(&xr); - if (kinv != NULL) /* dsa->kinv is NULL now if we used it */ - BN_clear_free(kinv); + BN_clear_free(kinv); return ret; } @@ -295,19 +293,16 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) if ((kinv = BN_mod_inverse(NULL, &k, dsa->q, ctx)) == NULL) goto err; - if (*kinvp != NULL) - BN_clear_free(*kinvp); + BN_clear_free(*kinvp); *kinvp = kinv; kinv = NULL; - if (*rp != NULL) - BN_clear_free(*rp); + BN_clear_free(*rp); *rp = r; ret = 1; err: if (!ret) { DSAerr(DSA_F_DSA_SIGN_SETUP, ERR_R_BN_LIB); - if (r != NULL) - BN_clear_free(r); + BN_clear_free(r); } if (ctx_in == NULL) BN_CTX_free(ctx); @@ -406,8 +401,7 @@ err: there is no error in BN. Test should be ret == -1 (Ben) */ if (ret != 1) DSAerr(DSA_F_DSA_DO_VERIFY, ERR_R_BN_LIB); - if (ctx != NULL) - BN_CTX_free(ctx); + BN_CTX_free(ctx); BN_free(&u1); BN_free(&u2); BN_free(&t1); @@ -424,8 +418,7 @@ dsa_init(DSA *dsa) static int dsa_finish(DSA *dsa) { - if (dsa->method_mont_p) - BN_MONT_CTX_free(dsa->method_mont_p); + BN_MONT_CTX_free(dsa->method_mont_p); return 1; } diff --git a/lib/libssl/src/crypto/dsa/dsa_sign.c b/lib/libssl/src/crypto/dsa/dsa_sign.c index efeb35477c4..80e002c4a7a 100644 --- a/lib/libssl/src/crypto/dsa/dsa_sign.c +++ b/lib/libssl/src/crypto/dsa/dsa_sign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_sign.c,v 1.17 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: dsa_sign.c,v 1.18 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -91,10 +91,8 @@ void DSA_SIG_free(DSA_SIG *sig) { if (sig) { - if (sig->r) - BN_free(sig->r); - if (sig->s) - BN_free(sig->s); + BN_free(sig->r); + BN_free(sig->s); free(sig); } } diff --git a/lib/libssl/src/crypto/ec/ec2_mult.c b/lib/libssl/src/crypto/ec/ec2_mult.c index 6c3a759dc8b..c74571f88c7 100644 --- a/lib/libssl/src/crypto/ec/ec2_mult.c +++ b/lib/libssl/src/crypto/ec/ec2_mult.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_mult.c,v 1.4 2014/07/10 22:45:56 jsing Exp $ */ +/* $OpenBSD: ec2_mult.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -421,12 +421,9 @@ ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, ret = 1; err: - if (p) - EC_POINT_free(p); - if (acc) - EC_POINT_free(acc); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + EC_POINT_free(p); + EC_POINT_free(acc); + BN_CTX_free(new_ctx); return ret; } diff --git a/lib/libssl/src/crypto/ec/ec2_oct.c b/lib/libssl/src/crypto/ec/ec2_oct.c index 5150423b993..3b8039af6ea 100644 --- a/lib/libssl/src/crypto/ec/ec2_oct.c +++ b/lib/libssl/src/crypto/ec/ec2_oct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_oct.c,v 1.4 2014/07/10 22:45:56 jsing Exp $ */ +/* $OpenBSD: ec2_oct.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -157,8 +157,7 @@ ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -267,15 +266,13 @@ ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, } if (used_ctx) BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; err: if (used_ctx) BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return 0; } @@ -375,8 +372,7 @@ ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } #endif diff --git a/lib/libssl/src/crypto/ec/ec2_smpl.c b/lib/libssl/src/crypto/ec/ec2_smpl.c index 001ffcc0774..0031a161c70 100644 --- a/lib/libssl/src/crypto/ec/ec2_smpl.c +++ b/lib/libssl/src/crypto/ec/ec2_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_smpl.c,v 1.11 2014/07/10 22:45:56 jsing Exp $ */ +/* $OpenBSD: ec2_smpl.c,v 1.12 2014/07/12 16:03:37 miod Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -310,8 +310,7 @@ ec_GF2m_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) err: if (ctx != NULL) BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -547,8 +546,7 @@ ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -641,8 +639,7 @@ ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX err: if (ctx) BN_CTX_end(ctx); - if (new_ctx) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -691,8 +688,7 @@ ec_GF2m_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * err: if (ctx) BN_CTX_end(ctx); - if (new_ctx) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -733,8 +729,7 @@ ec_GF2m_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ct err: if (ctx) BN_CTX_end(ctx); - if (new_ctx) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } diff --git a/lib/libssl/src/crypto/ec/ec_ameth.c b/lib/libssl/src/crypto/ec/ec_ameth.c index 93e305b71a5..c201815621a 100644 --- a/lib/libssl/src/crypto/ec/ec_ameth.c +++ b/lib/libssl/src/crypto/ec/ec_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_ameth.c,v 1.11 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: ec_ameth.c,v 1.12 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -492,12 +492,9 @@ do_EC_KEY_print(BIO * bp, const EC_KEY * x, int off, int ktype) err: if (!ret) ECerr(EC_F_DO_EC_KEY_PRINT, reason); - if (pub_key) - BN_free(pub_key); - if (order) - BN_free(order); - if (ctx) - BN_CTX_free(ctx); + BN_free(pub_key); + BN_free(order); + BN_CTX_free(ctx); free(buffer); return (ret); } diff --git a/lib/libssl/src/crypto/ec/ec_asn1.c b/lib/libssl/src/crypto/ec/ec_asn1.c index ef87b599f2c..c54f6593d59 100644 --- a/lib/libssl/src/crypto/ec/ec_asn1.c +++ b/lib/libssl/src/crypto/ec/ec_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_asn1.c,v 1.9 2014/07/10 22:45:57 jsing Exp $ */ +/* $OpenBSD: ec_asn1.c,v 1.10 2014/07/12 16:03:37 miod Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -404,8 +404,8 @@ ec_asn1_group2fieldid(const EC_GROUP * group, X9_62_FIELDID * field) ok = 1; -err: if (tmp) - BN_free(tmp); +err: + BN_free(tmp); return (ok); } @@ -509,12 +509,11 @@ ec_asn1_group2curve(const EC_GROUP * group, X9_62_CURVE * curve) ok = 1; -err: free(buffer_1); +err: + free(buffer_1); free(buffer_2); - if (tmp_1) - BN_free(tmp_1); - if (tmp_2) - BN_free(tmp_2); + BN_free(tmp_1); + BN_free(tmp_2); return (ok); } @@ -608,8 +607,7 @@ err: if (!ok) { ECPARAMETERS_free(ret); ret = NULL; } - if (tmp) - BN_free(tmp); + BN_free(tmp); free(buffer); return (ret); } @@ -849,10 +847,8 @@ ec_asn1_parameters2group(const ECPARAMETERS * params) } /* extract the cofactor (optional) */ if (params->cofactor == NULL) { - if (b) { - BN_free(b); - b = NULL; - } + BN_free(b); + b = NULL; } else if ((b = ASN1_INTEGER_to_BN(params->cofactor, b)) == NULL) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB); goto err; @@ -865,18 +861,13 @@ ec_asn1_parameters2group(const ECPARAMETERS * params) ok = 1; err: if (!ok) { - if (ret) - EC_GROUP_clear_free(ret); + EC_GROUP_clear_free(ret); ret = NULL; } - if (p) - BN_free(p); - if (a) - BN_free(a); - if (b) - BN_free(b); - if (point) - EC_POINT_free(point); + BN_free(p); + BN_free(a); + BN_free(b); + EC_POINT_free(point); return (ret); } @@ -992,8 +983,7 @@ d2i_ECPrivateKey(EC_KEY ** a, const unsigned char **in, long len) ret = *a; if (priv_key->parameters) { - if (ret->group) - EC_GROUP_clear_free(ret->group); + EC_GROUP_clear_free(ret->group); ret->group = ec_asn1_pkparameters2group(priv_key->parameters); } if (ret->group == NULL) { @@ -1022,8 +1012,7 @@ d2i_ECPrivateKey(EC_KEY ** a, const unsigned char **in, long len) const unsigned char *pub_oct; size_t pub_oct_len; - if (ret->pub_key) - EC_POINT_clear_free(ret->pub_key); + EC_POINT_clear_free(ret->pub_key); ret->pub_key = EC_POINT_new(ret->group); if (ret->pub_key == NULL) { ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); diff --git a/lib/libssl/src/crypto/ec/ec_check.c b/lib/libssl/src/crypto/ec/ec_check.c index 585590514f4..779e03cc2bf 100644 --- a/lib/libssl/src/crypto/ec/ec_check.c +++ b/lib/libssl/src/crypto/ec/ec_check.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_check.c,v 1.3 2014/06/12 15:49:29 deraadt Exp $ */ +/* $OpenBSD: ec_check.c,v 1.4 2014/07/12 16:03:37 miod Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -109,9 +109,7 @@ EC_GROUP_check(const EC_GROUP * group, BN_CTX * ctx) err: if (ctx != NULL) BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); - if (point) - EC_POINT_free(point); + BN_CTX_free(new_ctx); + EC_POINT_free(point); return ret; } diff --git a/lib/libssl/src/crypto/ec/ec_curve.c b/lib/libssl/src/crypto/ec/ec_curve.c index baac8c7156e..9d36d0bf229 100644 --- a/lib/libssl/src/crypto/ec/ec_curve.c +++ b/lib/libssl/src/crypto/ec/ec_curve.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_curve.c,v 1.6 2014/07/10 22:45:57 jsing Exp $ */ +/* $OpenBSD: ec_curve.c,v 1.7 2014/07/12 16:03:37 miod Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -2981,22 +2981,14 @@ err: EC_GROUP_free(group); group = NULL; } - if (P) - EC_POINT_free(P); - if (ctx) - BN_CTX_free(ctx); - if (p) - BN_free(p); - if (a) - BN_free(a); - if (b) - BN_free(b); - if (order) - BN_free(order); - if (x) - BN_free(x); - if (y) - BN_free(y); + EC_POINT_free(P); + BN_CTX_free(ctx); + BN_free(p); + BN_free(a); + BN_free(b); + BN_free(order); + BN_free(x); + BN_free(y); return group; } diff --git a/lib/libssl/src/crypto/ec/ec_key.c b/lib/libssl/src/crypto/ec/ec_key.c index 7067a949da3..1154c4dbf5b 100644 --- a/lib/libssl/src/crypto/ec/ec_key.c +++ b/lib/libssl/src/crypto/ec/ec_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_key.c,v 1.8 2014/07/10 22:45:57 jsing Exp $ */ +/* $OpenBSD: ec_key.c,v 1.9 2014/07/12 16:03:37 miod Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -116,12 +116,9 @@ EC_KEY_free(EC_KEY * r) if (i > 0) return; - if (r->group != NULL) - EC_GROUP_free(r->group); - if (r->pub_key != NULL) - EC_POINT_free(r->pub_key); - if (r->priv_key != NULL) - BN_clear_free(r->priv_key); + EC_GROUP_free(r->group); + EC_POINT_free(r->pub_key); + BN_clear_free(r->priv_key); EC_EX_DATA_free_all_data(&r->method_data); @@ -143,8 +140,7 @@ EC_KEY_copy(EC_KEY * dest, const EC_KEY * src) if (src->group) { const EC_METHOD *meth = EC_GROUP_method_of(src->group); /* clear the old group */ - if (dest->group) - EC_GROUP_free(dest->group); + EC_GROUP_free(dest->group); dest->group = EC_GROUP_new(meth); if (dest->group == NULL) return NULL; @@ -153,8 +149,7 @@ EC_KEY_copy(EC_KEY * dest, const EC_KEY * src) } /* copy the public key */ if (src->pub_key && src->group) { - if (dest->pub_key) - EC_POINT_free(dest->pub_key); + EC_POINT_free(dest->pub_key); dest->pub_key = EC_POINT_new(src->group); if (dest->pub_key == NULL) return NULL; @@ -261,14 +256,12 @@ EC_KEY_generate_key(EC_KEY * eckey) ok = 1; err: - if (order) - BN_free(order); + BN_free(order); if (pub_key != NULL && eckey->pub_key == NULL) EC_POINT_free(pub_key); if (priv_key != NULL && eckey->priv_key == NULL) BN_free(priv_key); - if (ctx != NULL) - BN_CTX_free(ctx); + BN_CTX_free(ctx); return (ok); } @@ -334,10 +327,8 @@ EC_KEY_check_key(const EC_KEY * eckey) } ok = 1; err: - if (ctx != NULL) - BN_CTX_free(ctx); - if (point != NULL) - EC_POINT_free(point); + BN_CTX_free(ctx); + EC_POINT_free(point); return (ok); } @@ -406,10 +397,8 @@ EC_KEY_set_public_key_affine_coordinates(EC_KEY * key, BIGNUM * x, BIGNUM * y) ok = 1; err: - if (ctx) - BN_CTX_free(ctx); - if (point) - EC_POINT_free(point); + BN_CTX_free(ctx); + EC_POINT_free(point); return ok; } @@ -423,8 +412,7 @@ EC_KEY_get0_group(const EC_KEY * key) int EC_KEY_set_group(EC_KEY * key, const EC_GROUP * group) { - if (key->group != NULL) - EC_GROUP_free(key->group); + EC_GROUP_free(key->group); key->group = EC_GROUP_dup(group); return (key->group == NULL) ? 0 : 1; } @@ -438,8 +426,7 @@ EC_KEY_get0_private_key(const EC_KEY * key) int EC_KEY_set_private_key(EC_KEY * key, const BIGNUM * priv_key) { - if (key->priv_key) - BN_clear_free(key->priv_key); + BN_clear_free(key->priv_key); key->priv_key = BN_dup(priv_key); return (key->priv_key == NULL) ? 0 : 1; } @@ -453,8 +440,7 @@ EC_KEY_get0_public_key(const EC_KEY * key) int EC_KEY_set_public_key(EC_KEY * key, const EC_POINT * pub_key) { - if (key->pub_key != NULL) - EC_POINT_free(key->pub_key); + EC_POINT_free(key->pub_key); key->pub_key = EC_POINT_dup(pub_key, key->group); return (key->pub_key == NULL) ? 0 : 1; } diff --git a/lib/libssl/src/crypto/ec/ec_lib.c b/lib/libssl/src/crypto/ec/ec_lib.c index 3d8b96eb1f3..47ccc614d1a 100644 --- a/lib/libssl/src/crypto/ec/ec_lib.c +++ b/lib/libssl/src/crypto/ec/ec_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_lib.c,v 1.14 2014/07/10 22:45:57 jsing Exp $ */ +/* $OpenBSD: ec_lib.c,v 1.15 2014/07/12 16:03:37 miod Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -124,8 +124,7 @@ EC_GROUP_free(EC_GROUP * group) EC_EX_DATA_free_all_data(&group->extra_data); - if (group->generator != NULL) - EC_POINT_free(group->generator); + EC_POINT_free(group->generator); BN_free(&group->order); BN_free(&group->cofactor); @@ -148,8 +147,7 @@ EC_GROUP_clear_free(EC_GROUP * group) EC_EX_DATA_clear_free_all_data(&group->extra_data); - if (group->generator != NULL) - EC_POINT_clear_free(group->generator); + EC_POINT_clear_free(group->generator); BN_clear_free(&group->order); BN_clear_free(&group->cofactor); @@ -200,10 +198,8 @@ EC_GROUP_copy(EC_GROUP * dest, const EC_GROUP * src) return 0; } else { /* src->generator == NULL */ - if (dest->generator != NULL) { - EC_POINT_clear_free(dest->generator); - dest->generator = NULL; - } + EC_POINT_clear_free(dest->generator); + dest->generator = NULL; } if (!BN_copy(&dest->order, &src->order)) @@ -252,8 +248,7 @@ EC_GROUP_dup(const EC_GROUP * a) err: if (!ok) { - if (t) - EC_GROUP_free(t); + EC_GROUP_free(t); return NULL; } else return t; diff --git a/lib/libssl/src/crypto/ec/ec_mult.c b/lib/libssl/src/crypto/ec/ec_mult.c index b6f74a1b09d..4e49ce4f7b1 100644 --- a/lib/libssl/src/crypto/ec/ec_mult.c +++ b/lib/libssl/src/crypto/ec/ec_mult.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_mult.c,v 1.13 2014/06/12 15:49:29 deraadt Exp $ */ +/* $OpenBSD: ec_mult.c,v 1.14 2014/07/12 16:03:37 miod Exp $ */ /* * Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project. */ @@ -679,10 +679,8 @@ ec_wNAF_mul(const EC_GROUP * group, EC_POINT * r, const BIGNUM * scalar, ret = 1; err: - if (new_ctx != NULL) - BN_CTX_free(new_ctx); - if (tmp != NULL) - EC_POINT_free(tmp); + BN_CTX_free(new_ctx); + EC_POINT_free(tmp); free(wsize); free(wNAF_len); if (wNAF != NULL) { @@ -862,10 +860,8 @@ ec_wNAF_precompute_mult(EC_GROUP * group, BN_CTX * ctx) err: if (ctx != NULL) BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); - if (pre_comp) - ec_pre_comp_free(pre_comp); + BN_CTX_free(new_ctx); + ec_pre_comp_free(pre_comp); if (points) { EC_POINT **p; @@ -873,10 +869,8 @@ err: EC_POINT_free(*p); free(points); } - if (tmp_point) - EC_POINT_free(tmp_point); - if (base) - EC_POINT_free(base); + EC_POINT_free(tmp_point); + EC_POINT_free(base); return ret; } diff --git a/lib/libssl/src/crypto/ec/ec_pmeth.c b/lib/libssl/src/crypto/ec/ec_pmeth.c index 7ba1d50d7f9..07933dc5fde 100644 --- a/lib/libssl/src/crypto/ec/ec_pmeth.c +++ b/lib/libssl/src/crypto/ec/ec_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_pmeth.c,v 1.7 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: ec_pmeth.c,v 1.8 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -114,8 +114,7 @@ pkey_ec_cleanup(EVP_PKEY_CTX * ctx) { EC_PKEY_CTX *dctx = ctx->data; if (dctx) { - if (dctx->gen_group) - EC_GROUP_free(dctx->gen_group); + EC_GROUP_free(dctx->gen_group); free(dctx); } } @@ -213,8 +212,7 @@ pkey_ec_ctrl(EVP_PKEY_CTX * ctx, int type, int p1, void *p2) ECerr(EC_F_PKEY_EC_CTRL, EC_R_INVALID_CURVE); return 0; } - if (dctx->gen_group) - EC_GROUP_free(dctx->gen_group); + EC_GROUP_free(dctx->gen_group); dctx->gen_group = group; return 1; diff --git a/lib/libssl/src/crypto/ec/eck_prn.c b/lib/libssl/src/crypto/ec/eck_prn.c index b0c8bcd22a8..aa13d8b08c4 100644 --- a/lib/libssl/src/crypto/ec/eck_prn.c +++ b/lib/libssl/src/crypto/ec/eck_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eck_prn.c,v 1.9 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: eck_prn.c,v 1.10 2014/07/12 16:03:37 miod Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -315,20 +315,13 @@ ECPKParameters_print(BIO * bp, const EC_GROUP * x, int off) err: if (!ret) ECerr(EC_F_ECPKPARAMETERS_PRINT, reason); - if (p) - BN_free(p); - if (a) - BN_free(a); - if (b) - BN_free(b); - if (gen) - BN_free(gen); - if (order) - BN_free(order); - if (cofactor) - BN_free(cofactor); - if (ctx) - BN_CTX_free(ctx); + BN_free(p); + BN_free(a); + BN_free(b); + BN_free(gen); + BN_free(order); + BN_free(cofactor); + BN_CTX_free(ctx); free(buffer); return (ret); } diff --git a/lib/libssl/src/crypto/ec/ecp_mont.c b/lib/libssl/src/crypto/ec/ecp_mont.c index ffbce81d4c9..af8014ed389 100644 --- a/lib/libssl/src/crypto/ec/ecp_mont.c +++ b/lib/libssl/src/crypto/ec/ecp_mont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_mont.c,v 1.8 2014/06/12 15:49:29 deraadt Exp $ */ +/* $OpenBSD: ecp_mont.c,v 1.9 2014/07/12 16:03:37 miod Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -128,14 +128,10 @@ ec_GFp_mont_group_init(EC_GROUP * group) void ec_GFp_mont_group_finish(EC_GROUP * group) { - if (group->field_data1 != NULL) { - BN_MONT_CTX_free(group->field_data1); - group->field_data1 = NULL; - } - if (group->field_data2 != NULL) { - BN_free(group->field_data2); - group->field_data2 = NULL; - } + BN_MONT_CTX_free(group->field_data1); + group->field_data1 = NULL; + BN_free(group->field_data2); + group->field_data2 = NULL; ec_GFp_simple_group_finish(group); } @@ -143,14 +139,10 @@ ec_GFp_mont_group_finish(EC_GROUP * group) void ec_GFp_mont_group_clear_finish(EC_GROUP * group) { - if (group->field_data1 != NULL) { - BN_MONT_CTX_free(group->field_data1); - group->field_data1 = NULL; - } - if (group->field_data2 != NULL) { - BN_clear_free(group->field_data2); - group->field_data2 = NULL; - } + BN_MONT_CTX_free(group->field_data1); + group->field_data1 = NULL; + BN_clear_free(group->field_data2); + group->field_data2 = NULL; ec_GFp_simple_group_clear_finish(group); } @@ -158,14 +150,11 @@ ec_GFp_mont_group_clear_finish(EC_GROUP * group) int ec_GFp_mont_group_copy(EC_GROUP * dest, const EC_GROUP * src) { - if (dest->field_data1 != NULL) { - BN_MONT_CTX_free(dest->field_data1); - dest->field_data1 = NULL; - } - if (dest->field_data2 != NULL) { - BN_clear_free(dest->field_data2); - dest->field_data2 = NULL; - } + BN_MONT_CTX_free(dest->field_data1); + dest->field_data1 = NULL; + BN_clear_free(dest->field_data2); + dest->field_data2 = NULL; + if (!ec_GFp_simple_group_copy(dest, src)) return 0; @@ -201,14 +190,10 @@ ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, BIGNUM *one = NULL; int ret = 0; - if (group->field_data1 != NULL) { - BN_MONT_CTX_free(group->field_data1); - group->field_data1 = NULL; - } - if (group->field_data2 != NULL) { - BN_free(group->field_data2); - group->field_data2 = NULL; - } + BN_MONT_CTX_free(group->field_data1); + group->field_data1 = NULL; + BN_free(group->field_data2); + group->field_data2 = NULL; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) @@ -241,10 +226,8 @@ ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, group->field_data2 = NULL; } err: - if (new_ctx != NULL) - BN_CTX_free(new_ctx); - if (mont != NULL) - BN_MONT_CTX_free(mont); + BN_CTX_free(new_ctx); + BN_MONT_CTX_free(mont); return ret; } diff --git a/lib/libssl/src/crypto/ec/ecp_nist.c b/lib/libssl/src/crypto/ec/ecp_nist.c index d49d1735f3b..a33f9d9e398 100644 --- a/lib/libssl/src/crypto/ec/ecp_nist.c +++ b/lib/libssl/src/crypto/ec/ecp_nist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nist.c,v 1.8 2014/06/12 15:49:29 deraadt Exp $ */ +/* $OpenBSD: ecp_nist.c,v 1.9 2014/07/12 16:03:37 miod Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -153,8 +153,7 @@ ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p, err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -181,8 +180,7 @@ ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, ret = 1; err: - if (ctx_new) - BN_CTX_free(ctx_new); + BN_CTX_free(ctx_new); return ret; } @@ -209,7 +207,6 @@ ec_GFp_nist_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, ret = 1; err: - if (ctx_new) - BN_CTX_free(ctx_new); + BN_CTX_free(ctx_new); return ret; } diff --git a/lib/libssl/src/crypto/ec/ecp_nistp224.c b/lib/libssl/src/crypto/ec/ecp_nistp224.c index c466d2db83c..ed0bad2a722 100644 --- a/lib/libssl/src/crypto/ec/ecp_nistp224.c +++ b/lib/libssl/src/crypto/ec/ecp_nistp224.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistp224.c,v 1.14 2014/07/10 22:45:57 jsing Exp $ */ +/* $OpenBSD: ecp_nistp224.c,v 1.15 2014/07/12 16:03:37 miod Exp $ */ /* * Written by Emilia Kasper (Google) for the OpenSSL project. */ @@ -1285,8 +1285,7 @@ ec_GFp_nistp224_group_set_curve(EC_GROUP * group, const BIGNUM * p, ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -1545,10 +1544,8 @@ ec_GFp_nistp224_points_mul(const EC_GROUP * group, EC_POINT * r, err: BN_CTX_end(ctx); - if (generator != NULL) - EC_POINT_free(generator); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + EC_POINT_free(generator); + BN_CTX_free(new_ctx); free(secrets); free(pre_comp); free(tmp_felems); @@ -1676,12 +1673,9 @@ ec_GFp_nistp224_precompute_mult(EC_GROUP * group, BN_CTX * ctx) pre = NULL; err: BN_CTX_end(ctx); - if (generator != NULL) - EC_POINT_free(generator); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); - if (pre) - nistp224_pre_comp_free(pre); + EC_POINT_free(generator); + BN_CTX_free(new_ctx); + nistp224_pre_comp_free(pre); return ret; } diff --git a/lib/libssl/src/crypto/ec/ecp_nistp256.c b/lib/libssl/src/crypto/ec/ecp_nistp256.c index 7b122e63071..6905b614bcd 100644 --- a/lib/libssl/src/crypto/ec/ecp_nistp256.c +++ b/lib/libssl/src/crypto/ec/ecp_nistp256.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistp256.c,v 1.13 2014/07/10 22:45:57 jsing Exp $ */ +/* $OpenBSD: ecp_nistp256.c,v 1.14 2014/07/12 16:03:37 miod Exp $ */ /* * Written by Adam Langley (Google) for the OpenSSL project */ @@ -1834,8 +1834,7 @@ ec_GFp_nistp256_group_set_curve(EC_GROUP * group, const BIGNUM * p, ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -2098,10 +2097,8 @@ ec_GFp_nistp256_points_mul(const EC_GROUP * group, EC_POINT * r, err: BN_CTX_end(ctx); - if (generator != NULL) - EC_POINT_free(generator); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + EC_POINT_free(generator); + BN_CTX_free(new_ctx); free(secrets); free(pre_comp); free(tmp_smallfelems); @@ -2223,12 +2220,9 @@ ec_GFp_nistp256_precompute_mult(EC_GROUP * group, BN_CTX * ctx) pre = NULL; err: BN_CTX_end(ctx); - if (generator != NULL) - EC_POINT_free(generator); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); - if (pre) - nistp256_pre_comp_free(pre); + EC_POINT_free(generator); + BN_CTX_free(new_ctx); + nistp256_pre_comp_free(pre); return ret; } diff --git a/lib/libssl/src/crypto/ec/ecp_nistp521.c b/lib/libssl/src/crypto/ec/ecp_nistp521.c index cec0a3b470f..c9313ada8e2 100644 --- a/lib/libssl/src/crypto/ec/ecp_nistp521.c +++ b/lib/libssl/src/crypto/ec/ecp_nistp521.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistp521.c,v 1.14 2014/07/10 22:45:57 jsing Exp $ */ +/* $OpenBSD: ecp_nistp521.c,v 1.15 2014/07/12 16:03:37 miod Exp $ */ /* * Written by Adam Langley (Google) for the OpenSSL project */ @@ -1725,8 +1725,7 @@ ec_GFp_nistp521_group_set_curve(EC_GROUP * group, const BIGNUM * p, ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -1985,10 +1984,8 @@ ec_GFp_nistp521_points_mul(const EC_GROUP * group, EC_POINT * r, err: BN_CTX_end(ctx); - if (generator != NULL) - EC_POINT_free(generator); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + EC_POINT_free(generator); + BN_CTX_free(new_ctx); free(secrets); free(pre_comp); free(tmp_felems); @@ -2096,12 +2093,9 @@ ec_GFp_nistp521_precompute_mult(EC_GROUP * group, BN_CTX * ctx) pre = NULL; err: BN_CTX_end(ctx); - if (generator != NULL) - EC_POINT_free(generator); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); - if (pre) - nistp521_pre_comp_free(pre); + EC_POINT_free(generator); + BN_CTX_free(new_ctx); + nistp521_pre_comp_free(pre); return ret; } diff --git a/lib/libssl/src/crypto/ec/ecp_oct.c b/lib/libssl/src/crypto/ec/ecp_oct.c index 2f2920d70db..d2402ee0d81 100644 --- a/lib/libssl/src/crypto/ec/ecp_oct.c +++ b/lib/libssl/src/crypto/ec/ecp_oct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_oct.c,v 1.4 2014/06/12 15:49:29 deraadt Exp $ */ +/* $OpenBSD: ecp_oct.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -190,8 +190,7 @@ ec_GFp_simple_set_compressed_coordinates(const EC_GROUP * group, EC_POINT * poin err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -290,15 +289,13 @@ ec_GFp_simple_point2oct(const EC_GROUP * group, const EC_POINT * point, point_co } if (used_ctx) BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; err: if (used_ctx) BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return 0; } @@ -391,7 +388,6 @@ ec_GFp_simple_oct2point(const EC_GROUP * group, EC_POINT * point, err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } diff --git a/lib/libssl/src/crypto/ec/ecp_smpl.c b/lib/libssl/src/crypto/ec/ecp_smpl.c index 5ba9a925d6e..dabc5af899b 100644 --- a/lib/libssl/src/crypto/ec/ecp_smpl.c +++ b/lib/libssl/src/crypto/ec/ecp_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_smpl.c,v 1.12 2014/06/12 15:49:29 deraadt Exp $ */ +/* $OpenBSD: ecp_smpl.c,v 1.13 2014/07/12 16:03:37 miod Exp $ */ /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -222,8 +222,7 @@ ec_GFp_simple_group_set_curve(EC_GROUP * group, err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -267,8 +266,7 @@ ec_GFp_simple_group_get_curve(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BI ret = 1; err: - if (new_ctx) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -348,8 +346,7 @@ ec_GFp_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) err: if (ctx != NULL) BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -457,8 +454,7 @@ ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP * group, EC_POINT * ret = 1; err: - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -506,8 +502,7 @@ ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP * group, const EC_P ret = 1; err: - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -626,8 +621,7 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POIN err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -810,8 +804,7 @@ ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, cons end: if (ctx) /* otherwise we already called BN_CTX_end */ BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -951,8 +944,7 @@ ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_C err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -1071,8 +1063,7 @@ ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -1172,8 +1163,7 @@ ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b end: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -1211,8 +1201,7 @@ ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); return ret; } @@ -1377,16 +1366,14 @@ ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT * err: BN_CTX_end(ctx); - if (new_ctx != NULL) - BN_CTX_free(new_ctx); + BN_CTX_free(new_ctx); if (heap != NULL) { /* * heap[pow2/2] .. heap[pow2-1] have not been allocated * locally! */ for (i = pow2 / 2 - 1; i > 0; i--) { - if (heap[i] != NULL) - BN_clear_free(heap[i]); + BN_clear_free(heap[i]); } free(heap); } diff --git a/lib/libssl/src/crypto/ecdh/ech_ossl.c b/lib/libssl/src/crypto/ecdh/ech_ossl.c index d82ace3670d..ee130edeee4 100644 --- a/lib/libssl/src/crypto/ecdh/ech_ossl.c +++ b/lib/libssl/src/crypto/ecdh/ech_ossl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ech_ossl.c,v 1.7 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: ech_ossl.c,v 1.8 2014/07/12 16:03:37 miod Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -201,9 +201,10 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, } err: - if (tmp) EC_POINT_free(tmp); - if (ctx) BN_CTX_end(ctx); - if (ctx) BN_CTX_free(ctx); + EC_POINT_free(tmp); + if (ctx) + BN_CTX_end(ctx); + BN_CTX_free(ctx); free(buf); return(ret); } diff --git a/lib/libssl/src/crypto/ecdsa/ecs_ossl.c b/lib/libssl/src/crypto/ecdsa/ecs_ossl.c index e2c4b1d6d14..0dde5386ffa 100644 --- a/lib/libssl/src/crypto/ecdsa/ecs_ossl.c +++ b/lib/libssl/src/crypto/ecdsa/ecs_ossl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_ossl.c,v 1.4 2014/07/10 22:45:57 jsing Exp $ */ +/* $OpenBSD: ecs_ossl.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ /* * Written by Nils Larsch for the OpenSSL project */ @@ -189,28 +189,22 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, goto err; } /* clear old values if necessary */ - if (*rp != NULL) - BN_clear_free(*rp); - if (*kinvp != NULL) - BN_clear_free(*kinvp); + BN_clear_free(*rp); + BN_clear_free(*kinvp); /* save the pre-computed values */ *rp = r; *kinvp = k; ret = 1; err: - if (!ret) - { - if (k != NULL) BN_clear_free(k); - if (r != NULL) BN_clear_free(r); + if (!ret) { + BN_clear_free(k); + BN_clear_free(r); } if (ctx_in == NULL) BN_CTX_free(ctx); - if (order != NULL) - BN_free(order); - if (tmp_point != NULL) - EC_POINT_free(tmp_point); - if (X) - BN_clear_free(X); + BN_free(order); + EC_POINT_free(tmp_point); + BN_clear_free(X); return(ret); } @@ -333,16 +327,11 @@ err: ECDSA_SIG_free(ret); ret = NULL; } - if (ctx) - BN_CTX_free(ctx); - if (m) - BN_clear_free(m); - if (tmp) - BN_clear_free(tmp); - if (order) - BN_free(order); - if (kinv) - BN_clear_free(kinv); + BN_CTX_free(ctx); + BN_clear_free(m); + BN_clear_free(tmp); + BN_free(order); + BN_clear_free(kinv); return ret; } @@ -473,7 +462,6 @@ static int ecdsa_do_verify(const unsigned char *dgst, int dgst_len, err: BN_CTX_end(ctx); BN_CTX_free(ctx); - if (point) - EC_POINT_free(point); + EC_POINT_free(point); return ret; } diff --git a/lib/libssl/src/crypto/engine/eng_rsax.c b/lib/libssl/src/crypto/engine/eng_rsax.c index daeb7e6ebbd..358dac20888 100644 --- a/lib/libssl/src/crypto/engine/eng_rsax.c +++ b/lib/libssl/src/crypto/engine/eng_rsax.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_rsax.c,v 1.9 2014/07/10 22:45:57 jsing Exp $ */ +/* $OpenBSD: eng_rsax.c,v 1.10 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (c) 2010-2010 Intel Corp. * Author: Vinodh.Gopal@intel.com * Jim Guilford @@ -307,12 +307,9 @@ e_rsax_rsa_finish(RSA *rsa) free(hptr); RSA_set_ex_data(rsa, rsax_ex_data_idx, NULL); } - if (rsa->_method_mod_n) - BN_MONT_CTX_free(rsa->_method_mod_n); - if (rsa->_method_mod_p) - BN_MONT_CTX_free(rsa->_method_mod_p); - if (rsa->_method_mod_q) - BN_MONT_CTX_free(rsa->_method_mod_q); + BN_MONT_CTX_free(rsa->_method_mod_n); + BN_MONT_CTX_free(rsa->_method_mod_p); + BN_MONT_CTX_free(rsa->_method_mod_q); return 1; } diff --git a/lib/libssl/src/crypto/evp/digest.c b/lib/libssl/src/crypto/evp/digest.c index 9a4b1a62936..d582d7954e5 100644 --- a/lib/libssl/src/crypto/evp/digest.c +++ b/lib/libssl/src/crypto/evp/digest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: digest.c,v 1.21 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: digest.c,v 1.22 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -358,8 +358,7 @@ EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) OPENSSL_cleanse(ctx->md_data, ctx->digest->ctx_size); free(ctx->md_data); } - if (ctx->pctx) - EVP_PKEY_CTX_free(ctx->pctx); + EVP_PKEY_CTX_free(ctx->pctx); #ifndef OPENSSL_NO_ENGINE if (ctx->engine) /* The EVP_MD we used belongs to an ENGINE, release the diff --git a/lib/libssl/src/crypto/evp/evp_pkey.c b/lib/libssl/src/crypto/evp/evp_pkey.c index cf7a39be7b8..38a324558f7 100644 --- a/lib/libssl/src/crypto/evp/evp_pkey.c +++ b/lib/libssl/src/crypto/evp/evp_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_pkey.c,v 1.16 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: evp_pkey.c,v 1.17 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -104,7 +104,7 @@ EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8) return pkey; error: - EVP_PKEY_free (pkey); + EVP_PKEY_free(pkey); return NULL; } diff --git a/lib/libssl/src/crypto/evp/pmeth_fn.c b/lib/libssl/src/crypto/evp/pmeth_fn.c index c4a53b0d5f4..4cf18a0be1e 100644 --- a/lib/libssl/src/crypto/evp/pmeth_fn.c +++ b/lib/libssl/src/crypto/evp/pmeth_fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmeth_fn.c,v 1.4 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: pmeth_fn.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -331,8 +331,7 @@ EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer) return -1; } - if (ctx->peerkey) - EVP_PKEY_free(ctx->peerkey); + EVP_PKEY_free(ctx->peerkey); ctx->peerkey = peer; ret = ctx->pmeth->ctrl(ctx, EVP_PKEY_CTRL_PEER_KEY, 1, peer); diff --git a/lib/libssl/src/crypto/evp/pmeth_gn.c b/lib/libssl/src/crypto/evp/pmeth_gn.c index 9eb10d48747..29f533625a5 100644 --- a/lib/libssl/src/crypto/evp/pmeth_gn.c +++ b/lib/libssl/src/crypto/evp/pmeth_gn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmeth_gn.c,v 1.4 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: pmeth_gn.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -222,7 +222,6 @@ EVP_PKEY_new_mac_key(int type, ENGINE *e, const unsigned char *key, int keylen) goto merr; merr: - if (mac_ctx) - EVP_PKEY_CTX_free(mac_ctx); + EVP_PKEY_CTX_free(mac_ctx); return mac_key; } diff --git a/lib/libssl/src/crypto/evp/pmeth_lib.c b/lib/libssl/src/crypto/evp/pmeth_lib.c index c9c3444a138..12267a6d933 100644 --- a/lib/libssl/src/crypto/evp/pmeth_lib.c +++ b/lib/libssl/src/crypto/evp/pmeth_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmeth_lib.c,v 1.8 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: pmeth_lib.c,v 1.9 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -371,10 +371,8 @@ EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx) return; if (ctx->pmeth && ctx->pmeth->cleanup) ctx->pmeth->cleanup(ctx); - if (ctx->pkey) - EVP_PKEY_free(ctx->pkey); - if (ctx->peerkey) - EVP_PKEY_free(ctx->peerkey); + EVP_PKEY_free(ctx->pkey); + EVP_PKEY_free(ctx->peerkey); #ifndef OPENSSL_NO_ENGINE if (ctx->engine) /* The EVP_PKEY_CTX we used belongs to an ENGINE, release the diff --git a/lib/libssl/src/crypto/pem/pem_pk8.c b/lib/libssl/src/crypto/pem/pem_pk8.c index dafbd13814b..8d7ac4a954a 100644 --- a/lib/libssl/src/crypto/pem/pem_pk8.c +++ b/lib/libssl/src/crypto/pem/pem_pk8.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pem_pk8.c,v 1.7 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: pem_pk8.c,v 1.8 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -184,8 +184,7 @@ d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u) if (!ret) return NULL; if (x) { - if (*x) - EVP_PKEY_free(*x); + EVP_PKEY_free(*x); *x = ret; } return ret; diff --git a/lib/libssl/src/crypto/pem/pem_pkey.c b/lib/libssl/src/crypto/pem/pem_pkey.c index 7e5e4f57718..a50742a63d1 100644 --- a/lib/libssl/src/crypto/pem/pem_pkey.c +++ b/lib/libssl/src/crypto/pem/pem_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pem_pkey.c,v 1.17 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: pem_pkey.c,v 1.18 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -99,8 +99,7 @@ PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u) goto p8err; ret = EVP_PKCS82PKEY(p8inf); if (x) { - if (*x) - EVP_PKEY_free((EVP_PKEY *)*x); + EVP_PKEY_free(*x); *x = ret; } PKCS8_PRIV_KEY_INFO_free(p8inf); @@ -128,8 +127,7 @@ PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u) goto p8err; ret = EVP_PKCS82PKEY(p8inf); if (x) { - if (*x) - EVP_PKEY_free((EVP_PKEY *)*x); + EVP_PKEY_free(*x); *x = ret; } PKCS8_PRIV_KEY_INFO_free(p8inf); @@ -194,8 +192,7 @@ PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x) goto err; } if (x) { - if (*x) - EVP_PKEY_free((EVP_PKEY *)*x); + EVP_PKEY_free(*x); *x = ret; } } diff --git a/lib/libssl/src/crypto/pem/pvkfmt.c b/lib/libssl/src/crypto/pem/pvkfmt.c index 32fcc181f74..ca7e908c294 100644 --- a/lib/libssl/src/crypto/pem/pvkfmt.c +++ b/lib/libssl/src/crypto/pem/pvkfmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pvkfmt.c,v 1.10 2014/07/11 15:35:53 miod Exp $ */ +/* $OpenBSD: pvkfmt.c,v 1.11 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2005. */ @@ -349,12 +349,9 @@ b2i_dss(const unsigned char **in, unsigned int length, unsigned int bitlen, memerr: PEMerr(PEM_F_B2I_DSS, ERR_R_MALLOC_FAILURE); - if (dsa) - DSA_free(dsa); - if (ret) - EVP_PKEY_free(ret); - if (ctx) - BN_CTX_free(ctx); + DSA_free(dsa); + EVP_PKEY_free(ret); + BN_CTX_free(ctx); return NULL; } @@ -402,10 +399,8 @@ b2i_rsa(const unsigned char **in, unsigned int length, unsigned int bitlen, memerr: PEMerr(PEM_F_B2I_RSA, ERR_R_MALLOC_FAILURE); - if (rsa) - RSA_free(rsa); - if (ret) - EVP_PKEY_free(ret); + RSA_free(rsa); + EVP_PKEY_free(ret); return NULL; } diff --git a/lib/libssl/src/crypto/pkcs12/p12_key.c b/lib/libssl/src/crypto/pkcs12/p12_key.c index 1f7583084ee..0357c2bfa2e 100644 --- a/lib/libssl/src/crypto/pkcs12/p12_key.c +++ b/lib/libssl/src/crypto/pkcs12/p12_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_key.c,v 1.20 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: p12_key.c,v 1.21 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -195,12 +195,12 @@ err: PKCS12err(PKCS12_F_PKCS12_KEY_GEN_UNI, ERR_R_MALLOC_FAILURE); end: - free (Ai); - free (B); - free (D); - free (I); - BN_free (Ij); - BN_free (Bpl1); + free(Ai); + free(B); + free(D); + free(I); + BN_free(Ij); + BN_free(Bpl1); EVP_MD_CTX_cleanup(&ctx); return ret; } diff --git a/lib/libssl/src/crypto/pkcs7/pk7_doit.c b/lib/libssl/src/crypto/pkcs7/pk7_doit.c index 4556949456f..cc6fd97b9de 100644 --- a/lib/libssl/src/crypto/pkcs7/pk7_doit.c +++ b/lib/libssl/src/crypto/pkcs7/pk7_doit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk7_doit.c,v 1.27 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: pk7_doit.c,v 1.28 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -184,10 +184,8 @@ pkcs7_encode_rinfo(PKCS7_RECIP_INFO *ri, unsigned char *key, int keylen) ret = 1; err: - if (pkey) - EVP_PKEY_free(pkey); - if (pctx) - EVP_PKEY_CTX_free(pctx); + EVP_PKEY_free(pkey); + EVP_PKEY_CTX_free(pctx); free(ek); return ret; } @@ -244,8 +242,7 @@ pkcs7_decrypt_rinfo(unsigned char **pek, int *peklen, PKCS7_RECIP_INFO *ri, *peklen = eklen; err: - if (pctx) - EVP_PKEY_CTX_free(pctx); + EVP_PKEY_CTX_free(pctx); if (!ret && ek) free(ek); diff --git a/lib/libssl/src/crypto/pkcs7/pk7_lib.c b/lib/libssl/src/crypto/pkcs7/pk7_lib.c index 699f5df3941..27370800c97 100644 --- a/lib/libssl/src/crypto/pkcs7/pk7_lib.c +++ b/lib/libssl/src/crypto/pkcs7/pk7_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk7_lib.c,v 1.13 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: pk7_lib.c,v 1.14 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -575,8 +575,7 @@ PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509) return 1; err: - if (pkey) - EVP_PKEY_free(pkey); + EVP_PKEY_free(pkey); return 0; } diff --git a/lib/libssl/src/crypto/rsa/rsa.h b/lib/libssl/src/crypto/rsa/rsa.h index d15d1f1c97d..8139db0b7d3 100644 --- a/lib/libssl/src/crypto/rsa/rsa.h +++ b/lib/libssl/src/crypto/rsa/rsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa.h,v 1.25 2014/07/10 22:45:57 jsing Exp $ */ +/* $OpenBSD: rsa.h,v 1.26 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -287,7 +287,7 @@ int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding); int RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding); -void RSA_free (RSA *r); +void RSA_free(RSA *r); /* "up" the RSA object's reference count */ int RSA_up_ref(RSA *r); diff --git a/lib/libssl/src/crypto/rsa/rsa_saos.c b/lib/libssl/src/crypto/rsa/rsa_saos.c index 47b2a4e95fa..adf459ee6df 100644 --- a/lib/libssl/src/crypto/rsa/rsa_saos.c +++ b/lib/libssl/src/crypto/rsa/rsa_saos.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_saos.c,v 1.15 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: rsa_saos.c,v 1.16 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -140,8 +140,7 @@ RSA_verify_ASN1_OCTET_STRING(int dtype, const unsigned char *m, } else ret = 1; err: - if (sig != NULL) - M_ASN1_OCTET_STRING_free(sig); + M_ASN1_OCTET_STRING_free(sig); if (s != NULL) { OPENSSL_cleanse(s, (unsigned int)siglen); free(s); diff --git a/lib/libssl/src/crypto/ts/ts_rsp_sign.c b/lib/libssl/src/crypto/ts/ts_rsp_sign.c index 9d20e66f9aa..27659e8f458 100644 --- a/lib/libssl/src/crypto/ts/ts_rsp_sign.c +++ b/lib/libssl/src/crypto/ts/ts_rsp_sign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts_rsp_sign.c,v 1.17 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: ts_rsp_sign.c,v 1.18 2014/07/12 16:03:37 miod Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ @@ -195,8 +195,7 @@ TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer) int TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key) { - if (ctx->signer_key) - EVP_PKEY_free(ctx->signer_key); + EVP_PKEY_free(ctx->signer_key); ctx->signer_key = key; CRYPTO_add(&ctx->signer_key->references, +1, CRYPTO_LOCK_EVP_PKEY); diff --git a/lib/libssl/src/crypto/x509/x509_cmp.c b/lib/libssl/src/crypto/x509/x509_cmp.c index e26866dc801..b63faaad2c8 100644 --- a/lib/libssl/src/crypto/x509/x509_cmp.c +++ b/lib/libssl/src/crypto/x509/x509_cmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_cmp.c,v 1.22 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: x509_cmp.c,v 1.23 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -358,8 +358,7 @@ X509_check_private_key(X509 *x, EVP_PKEY *k) X509err(X509_F_X509_CHECK_PRIVATE_KEY, X509_R_UNKNOWN_KEY_TYPE); } - if (xk) - EVP_PKEY_free(xk); + EVP_PKEY_free(xk); if (ret > 0) return 1; return 0; diff --git a/lib/libssl/src/ssl/ssl_lib.c b/lib/libssl/src/ssl/ssl_lib.c index beb8089475a..db310de881b 100644 --- a/lib/libssl/src/ssl/ssl_lib.c +++ b/lib/libssl/src/ssl/ssl_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_lib.c,v 1.75 2014/07/12 13:11:53 jsing Exp $ */ +/* $OpenBSD: ssl_lib.c,v 1.76 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -355,8 +355,7 @@ err: if (s != NULL) { if (s->cert != NULL) ssl_cert_free(s->cert); - if (s->ctx != NULL) - SSL_CTX_free(s->ctx); /* decrement reference count */ + SSL_CTX_free(s->ctx); /* decrement reference count */ free(s); } SSLerr(SSL_F_SSL_NEW, @@ -528,8 +527,7 @@ SSL_free(SSL *s) /* Free up if allocated */ free(s->tlsext_hostname); - if (s->initial_ctx) - SSL_CTX_free(s->initial_ctx); + SSL_CTX_free(s->initial_ctx); free(s->tlsext_ecpointformatlist); free(s->tlsext_ellipticcurvelist); if (s->tlsext_ocsp_exts) @@ -545,8 +543,7 @@ SSL_free(SSL *s) if (s->method != NULL) s->method->ssl_free(s); - if (s->ctx) - SSL_CTX_free(s->ctx); + SSL_CTX_free(s->ctx); #ifndef OPENSSL_NO_NEXTPROTONEG @@ -1831,8 +1828,7 @@ err: SSLerr(SSL_F_SSL_CTX_NEW, ERR_R_MALLOC_FAILURE); err2: - if (ret != NULL) - SSL_CTX_free(ret); + SSL_CTX_free(ret); return (NULL); } @@ -2725,8 +2721,7 @@ SSL_set_SSL_CTX(SSL *ssl, SSL_CTX* ctx) ssl_cert_free(ssl->cert); ssl->cert = ssl_cert_dup(ctx->cert); CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX); - if (ssl->ctx != NULL) - SSL_CTX_free(ssl->ctx); /* decrement reference count */ + SSL_CTX_free(ssl->ctx); /* decrement reference count */ ssl->ctx = ctx; return (ssl->ctx); } diff --git a/lib/libssl/src/ssl/ssl_rsa.c b/lib/libssl/src/ssl/ssl_rsa.c index c1d24cad525..d4d14bad357 100644 --- a/lib/libssl/src/ssl/ssl_rsa.c +++ b/lib/libssl/src/ssl/ssl_rsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_rsa.c,v 1.15 2014/06/22 19:09:37 guenther Exp $ */ +/* $OpenBSD: ssl_rsa.c,v 1.16 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -201,8 +201,7 @@ ssl_set_pkey(CERT *c, EVP_PKEY *pkey) } } - if (c->pkeys[i].privatekey != NULL) - EVP_PKEY_free(c->pkeys[i].privatekey); + EVP_PKEY_free(c->pkeys[i].privatekey); CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY); c->pkeys[i].privatekey = pkey; c->key = &(c->pkeys[i]); |