From 64b25758edca688a30f02c260262150f7ad0bc7d Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Thu, 3 Sep 2015 09:15:26 -0400 Subject: remove 0 assignments. After openssl_zalloc, cleanup more "set to 0/NULL" assignments. Many are from github feedback. Reviewed-by: Tim Hudson --- crypto/dh/dh_lib.c | 15 +-------------- crypto/dh/dh_pmeth.c | 12 ++---------- 2 files changed, 3 insertions(+), 24 deletions(-) (limited to 'crypto/dh') diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c index 4e087d0357..49f82d867f 100644 --- a/crypto/dh/dh_lib.c +++ b/crypto/dh/dh_lib.c @@ -107,7 +107,7 @@ DH *DH_new(void) DH *DH_new_method(ENGINE *engine) { - DH *ret = OPENSSL_malloc(sizeof(*ret)); + DH *ret = OPENSSL_zalloc(sizeof(*ret)); if (ret == NULL) { DHerr(DH_F_DH_NEW_METHOD, ERR_R_MALLOC_FAILURE); @@ -136,19 +136,6 @@ DH *DH_new_method(ENGINE *engine) } #endif - ret->pad = 0; - ret->version = 0; - ret->p = NULL; - ret->g = NULL; - ret->length = 0; - ret->pub_key = NULL; - ret->priv_key = NULL; - ret->q = NULL; - ret->j = NULL; - ret->seed = NULL; - ret->seedlen = 0; - ret->counter = NULL; - ret->method_mont_p = NULL; ret->references = 1; ret->flags = ret->meth->flags; CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data); diff --git a/crypto/dh/dh_pmeth.c b/crypto/dh/dh_pmeth.c index 751428cb66..ff27221644 100644 --- a/crypto/dh/dh_pmeth.c +++ b/crypto/dh/dh_pmeth.c @@ -98,22 +98,14 @@ typedef struct { static int pkey_dh_init(EVP_PKEY_CTX *ctx) { DH_PKEY_CTX *dctx; - dctx = OPENSSL_malloc(sizeof(*dctx)); + + dctx = OPENSSL_zalloc(sizeof(*dctx)); if (!dctx) return 0; dctx->prime_len = 1024; dctx->subprime_len = -1; dctx->generator = 2; - dctx->use_dsa = 0; - dctx->md = NULL; - dctx->rfc5114_param = 0; - dctx->kdf_type = EVP_PKEY_DH_KDF_NONE; - dctx->kdf_oid = NULL; - dctx->kdf_md = NULL; - dctx->kdf_ukm = NULL; - dctx->kdf_ukmlen = 0; - dctx->kdf_outlen = 0; ctx->data = dctx; ctx->keygen_info = dctx->gentmp; -- cgit v1.2.3