From cfe5d70bc21d1457c7a07fbdbeb7f5d74ceeafa6 Mon Sep 17 00:00:00 2001 From: tb <> Date: Thu, 24 May 2018 07:49:46 +0000 Subject: As calloc does the zeroing for us in EVP_PKEY_asn1_new() already, no need to do it a second time by hand, badly. While here, do some style cleanup. This incomplete list of function pointers appears in EVP_PKEY_asn1_copy() as well, fix it by adding sig_print to the members copied over. ok bcook --- src/lib/libcrypto/asn1/ameth_lib.c | 52 ++++++++------------------------------ 1 file changed, 10 insertions(+), 42 deletions(-) diff --git a/src/lib/libcrypto/asn1/ameth_lib.c b/src/lib/libcrypto/asn1/ameth_lib.c index d1798cf4f6..50d8735ea7 100644 --- a/src/lib/libcrypto/asn1/ameth_lib.c +++ b/src/lib/libcrypto/asn1/ameth_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ameth_lib.c,v 1.17 2018/05/13 06:40:55 tb Exp $ */ +/* $OpenBSD: ameth_lib.c,v 1.18 2018/05/24 07:49:46 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -309,59 +309,26 @@ EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info) { EVP_PKEY_ASN1_METHOD *ameth; - ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD)); - if (!ameth) + if ((ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD))) == NULL) return NULL; ameth->pkey_id = id; ameth->pkey_base_id = id; ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; - if (info) { - ameth->info = strdup(info); - if (!ameth->info) + if (info != NULL) { + if ((ameth->info = strdup(info)) == NULL) goto err; - } else - ameth->info = NULL; + } - if (pem_str) { - ameth->pem_str = strdup(pem_str); - if (!ameth->pem_str) + if (pem_str != NULL) { + if ((ameth->pem_str = strdup(pem_str)) == NULL) goto err; - } else - ameth->pem_str = NULL; - - ameth->pub_decode = 0; - ameth->pub_encode = 0; - ameth->pub_cmp = 0; - ameth->pub_print = 0; - - ameth->priv_decode = 0; - ameth->priv_encode = 0; - ameth->priv_print = 0; - - ameth->old_priv_encode = 0; - ameth->old_priv_decode = 0; - - ameth->item_verify = 0; - ameth->item_sign = 0; - - ameth->pkey_size = 0; - ameth->pkey_bits = 0; - - ameth->param_decode = 0; - ameth->param_encode = 0; - ameth->param_missing = 0; - ameth->param_copy = 0; - ameth->param_cmp = 0; - ameth->param_print = 0; - - ameth->pkey_free = 0; - ameth->pkey_ctrl = 0; + } return ameth; -err: + err: EVP_PKEY_asn1_free(ameth); return NULL; } @@ -390,6 +357,7 @@ EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, const EVP_PKEY_ASN1_METHOD *src) dst->param_copy = src->param_copy; dst->param_cmp = src->param_cmp; dst->param_print = src->param_print; + dst->sig_print = src->sig_print; dst->pkey_free = src->pkey_free; dst->pkey_ctrl = src->pkey_ctrl; -- cgit v1.2.3-55-g6feb