Skip to content

Commit a7b96f3

Browse files
author
tb
committed
pkey_hmac_init(): use calloc()
Instead of using malloc() and setting most struct members to 0, simply use calloc(). ok bcook jsing
1 parent 14a3642 commit a7b96f3

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/lib/libcrypto/hmac/hm_pmeth.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: hm_pmeth.c,v 1.11 2021/12/12 21:27:38 tb Exp $ */
1+
/* $OpenBSD: hm_pmeth.c,v 1.12 2022/03/30 07:12:30 tb Exp $ */
22
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
33
* project 2007.
44
*/
@@ -80,13 +80,9 @@ pkey_hmac_init(EVP_PKEY_CTX *ctx)
8080
{
8181
HMAC_PKEY_CTX *hctx;
8282

83-
hctx = malloc(sizeof(HMAC_PKEY_CTX));
84-
if (!hctx)
83+
if ((hctx = calloc(1, sizeof(HMAC_PKEY_CTX))) == NULL)
8584
return 0;
86-
hctx->md = NULL;
87-
hctx->ktmp.data = NULL;
88-
hctx->ktmp.length = 0;
89-
hctx->ktmp.flags = 0;
85+
9086
hctx->ktmp.type = V_ASN1_OCTET_STRING;
9187
HMAC_CTX_init(&hctx->ctx);
9288

0 commit comments

Comments
 (0)