summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2018-05-24 07:49:46 +0000
committertb <>2018-05-24 07:49:46 +0000
commitcfe5d70bc21d1457c7a07fbdbeb7f5d74ceeafa6 (patch)
tree1ab0b5d761d65e9f453e40c2e7a90a8289d5a9c5
parent0887dbf31e3858bede984af483fa561fb903c5ad (diff)
downloadopenbsd-cfe5d70bc21d1457c7a07fbdbeb7f5d74ceeafa6.tar.gz
openbsd-cfe5d70bc21d1457c7a07fbdbeb7f5d74ceeafa6.tar.bz2
openbsd-cfe5d70bc21d1457c7a07fbdbeb7f5d74ceeafa6.zip
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
-rw-r--r--src/lib/libcrypto/asn1/ameth_lib.c52
1 files 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 @@
1/* $OpenBSD: ameth_lib.c,v 1.17 2018/05/13 06:40:55 tb Exp $ */ 1/* $OpenBSD: ameth_lib.c,v 1.18 2018/05/24 07:49:46 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -309,59 +309,26 @@ EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info)
309{ 309{
310 EVP_PKEY_ASN1_METHOD *ameth; 310 EVP_PKEY_ASN1_METHOD *ameth;
311 311
312 ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD)); 312 if ((ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD))) == NULL)
313 if (!ameth)
314 return NULL; 313 return NULL;
315 314
316 ameth->pkey_id = id; 315 ameth->pkey_id = id;
317 ameth->pkey_base_id = id; 316 ameth->pkey_base_id = id;
318 ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; 317 ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC;
319 318
320 if (info) { 319 if (info != NULL) {
321 ameth->info = strdup(info); 320 if ((ameth->info = strdup(info)) == NULL)
322 if (!ameth->info)
323 goto err; 321 goto err;
324 } else 322 }
325 ameth->info = NULL;
326 323
327 if (pem_str) { 324 if (pem_str != NULL) {
328 ameth->pem_str = strdup(pem_str); 325 if ((ameth->pem_str = strdup(pem_str)) == NULL)
329 if (!ameth->pem_str)
330 goto err; 326 goto err;
331 } else 327 }
332 ameth->pem_str = NULL;
333
334 ameth->pub_decode = 0;
335 ameth->pub_encode = 0;
336 ameth->pub_cmp = 0;
337 ameth->pub_print = 0;
338
339 ameth->priv_decode = 0;
340 ameth->priv_encode = 0;
341 ameth->priv_print = 0;
342
343 ameth->old_priv_encode = 0;
344 ameth->old_priv_decode = 0;
345
346 ameth->item_verify = 0;
347 ameth->item_sign = 0;
348
349 ameth->pkey_size = 0;
350 ameth->pkey_bits = 0;
351
352 ameth->param_decode = 0;
353 ameth->param_encode = 0;
354 ameth->param_missing = 0;
355 ameth->param_copy = 0;
356 ameth->param_cmp = 0;
357 ameth->param_print = 0;
358
359 ameth->pkey_free = 0;
360 ameth->pkey_ctrl = 0;
361 328
362 return ameth; 329 return ameth;
363 330
364err: 331 err:
365 EVP_PKEY_asn1_free(ameth); 332 EVP_PKEY_asn1_free(ameth);
366 return NULL; 333 return NULL;
367} 334}
@@ -390,6 +357,7 @@ EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, const EVP_PKEY_ASN1_METHOD *src)
390 dst->param_copy = src->param_copy; 357 dst->param_copy = src->param_copy;
391 dst->param_cmp = src->param_cmp; 358 dst->param_cmp = src->param_cmp;
392 dst->param_print = src->param_print; 359 dst->param_print = src->param_print;
360 dst->sig_print = src->sig_print;
393 361
394 dst->pkey_free = src->pkey_free; 362 dst->pkey_free = src->pkey_free;
395 dst->pkey_ctrl = src->pkey_ctrl; 363 dst->pkey_ctrl = src->pkey_ctrl;