From: tb Date: Thu, 5 May 2022 19:48:06 +0000 (+0000) Subject: Simplify: freezero() is NULL safe; assign + test in one go, as usual. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0913730decc899869bce04777b5d527f62f20494;p=openbsd Simplify: freezero() is NULL safe; assign + test in one go, as usual. ok jsing --- diff --git a/lib/libcrypto/kdf/hkdf_evp.c b/lib/libcrypto/kdf/hkdf_evp.c index dd796657786..736208ded51 100644 --- a/lib/libcrypto/kdf/hkdf_evp.c +++ b/lib/libcrypto/kdf/hkdf_evp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hkdf_evp.c,v 1.17 2022/05/05 19:46:36 tb Exp $ */ +/* $OpenBSD: hkdf_evp.c,v 1.18 2022/05/05 19:48:06 tb Exp $ */ /* ==================================================================== * Copyright (c) 2016-2018 The OpenSSL Project. All rights reserved. * @@ -120,11 +120,8 @@ pkey_hkdf_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) if (p1 < 0) return 0; - if (kctx->salt != NULL) - freezero(kctx->salt, kctx->salt_len); - - kctx->salt = malloc(p1); - if (kctx->salt == NULL) + freezero(kctx->salt, kctx->salt_len); + if ((kctx->salt = malloc(p1)) == NULL) return 0; memcpy(kctx->salt, p2, p1); @@ -135,11 +132,8 @@ pkey_hkdf_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) if (p1 <= 0) return 0; - if (kctx->key != NULL) - freezero(kctx->key, kctx->key_len); - - kctx->key = malloc(p1); - if (kctx->key == NULL) + freezero(kctx->key, kctx->key_len); + if ((kctx->key = malloc(p1)) == NULL) return 0; memcpy(kctx->key, p2, p1);