diff options
author | 2019-04-14 17:16:57 +0000 | |
---|---|---|
committer | 2019-04-14 17:16:57 +0000 | |
commit | f7bc55d5894c2aca2db39b30f0dc128574ecb34b (patch) | |
tree | f5d62220d72a8f82573b7ac61be6e60cb155ca00 /lib/libcrypto/evp/evp_enc.c | |
parent | Annotate a future improvement. (diff) | |
download | wireguard-openbsd-f7bc55d5894c2aca2db39b30f0dc128574ecb34b.tar.xz wireguard-openbsd-f7bc55d5894c2aca2db39b30f0dc128574ecb34b.zip |
Use calloc() when allocating cipher_data.
Avoids use of uninitialised memory.
ok tb@
Diffstat (limited to 'lib/libcrypto/evp/evp_enc.c')
-rw-r--r-- | lib/libcrypto/evp/evp_enc.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libcrypto/evp/evp_enc.c b/lib/libcrypto/evp/evp_enc.c index 71ed70a2158..bb49e28267a 100644 --- a/lib/libcrypto/evp/evp_enc.c +++ b/lib/libcrypto/evp/evp_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_enc.c,v 1.42 2019/04/14 16:46:26 jsing Exp $ */ +/* $OpenBSD: evp_enc.c,v 1.43 2019/04/14 17:16:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -144,8 +144,8 @@ EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, ctx->cipher = cipher; if (ctx->cipher->ctx_size) { - ctx->cipher_data = malloc(ctx->cipher->ctx_size); - if (!ctx->cipher_data) { + ctx->cipher_data = calloc(1, ctx->cipher->ctx_size); + if (ctx->cipher_data == NULL) { EVPerror(ERR_R_MALLOC_FAILURE); return 0; } @@ -667,8 +667,8 @@ EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in) memcpy(out, in, sizeof *out); if (in->cipher_data && in->cipher->ctx_size) { - out->cipher_data = malloc(in->cipher->ctx_size); - if (!out->cipher_data) { + out->cipher_data = calloc(1, in->cipher->ctx_size); + if (out->cipher_data == NULL) { EVPerror(ERR_R_MALLOC_FAILURE); return 0; } |