summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2014-06-15 15:46:22 +0000
committerjsing <>2014-06-15 15:46:22 +0000
commit9f854fb85a6b6747c90f31c5816701dfdb8769a9 (patch)
treed2c2643cbaff4a68a03c97ee70dbb6e694b3c3a7 /src
parent38a8ba4b0cb305320f7f52da8803cb7415a1b19e (diff)
downloadopenbsd-9f854fb85a6b6747c90f31c5816701dfdb8769a9.tar.gz
openbsd-9f854fb85a6b6747c90f31c5816701dfdb8769a9.tar.bz2
openbsd-9f854fb85a6b6747c90f31c5816701dfdb8769a9.zip
Simplify EVP_MD_CTX_create() by just using calloc(). Also, use 0 rather
than '\0' for several memset(). ok beck@ miod@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/evp/digest.c13
-rw-r--r--src/lib/libssl/src/crypto/evp/digest.c13
2 files changed, 8 insertions, 18 deletions
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c
index 4071d71e1e..f598e78911 100644
--- a/src/lib/libcrypto/evp/digest.c
+++ b/src/lib/libcrypto/evp/digest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: digest.c,v 1.17 2014/06/12 15:49:29 deraadt Exp $ */ 1/* $OpenBSD: digest.c,v 1.18 2014/06/15 15:46:22 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -120,18 +120,13 @@
120void 120void
121EVP_MD_CTX_init(EVP_MD_CTX *ctx) 121EVP_MD_CTX_init(EVP_MD_CTX *ctx)
122{ 122{
123 memset(ctx, '\0', sizeof *ctx); 123 memset(ctx, 0, sizeof *ctx);
124} 124}
125 125
126EVP_MD_CTX * 126EVP_MD_CTX *
127EVP_MD_CTX_create(void) 127EVP_MD_CTX_create(void)
128{ 128{
129 EVP_MD_CTX *ctx = malloc(sizeof *ctx); 129 return calloc(1, sizeof(EVP_MD_CTX));
130
131 if (ctx)
132 EVP_MD_CTX_init(ctx);
133
134 return ctx;
135} 130}
136 131
137int 132int
@@ -367,7 +362,7 @@ EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
367 * functional reference we held for this reason. */ 362 * functional reference we held for this reason. */
368 ENGINE_finish(ctx->engine); 363 ENGINE_finish(ctx->engine);
369#endif 364#endif
370 memset(ctx, '\0', sizeof *ctx); 365 memset(ctx, 0, sizeof *ctx);
371 366
372 return 1; 367 return 1;
373} 368}
diff --git a/src/lib/libssl/src/crypto/evp/digest.c b/src/lib/libssl/src/crypto/evp/digest.c
index 4071d71e1e..f598e78911 100644
--- a/src/lib/libssl/src/crypto/evp/digest.c
+++ b/src/lib/libssl/src/crypto/evp/digest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: digest.c,v 1.17 2014/06/12 15:49:29 deraadt Exp $ */ 1/* $OpenBSD: digest.c,v 1.18 2014/06/15 15:46:22 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -120,18 +120,13 @@
120void 120void
121EVP_MD_CTX_init(EVP_MD_CTX *ctx) 121EVP_MD_CTX_init(EVP_MD_CTX *ctx)
122{ 122{
123 memset(ctx, '\0', sizeof *ctx); 123 memset(ctx, 0, sizeof *ctx);
124} 124}
125 125
126EVP_MD_CTX * 126EVP_MD_CTX *
127EVP_MD_CTX_create(void) 127EVP_MD_CTX_create(void)
128{ 128{
129 EVP_MD_CTX *ctx = malloc(sizeof *ctx); 129 return calloc(1, sizeof(EVP_MD_CTX));
130
131 if (ctx)
132 EVP_MD_CTX_init(ctx);
133
134 return ctx;
135} 130}
136 131
137int 132int
@@ -367,7 +362,7 @@ EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
367 * functional reference we held for this reason. */ 362 * functional reference we held for this reason. */
368 ENGINE_finish(ctx->engine); 363 ENGINE_finish(ctx->engine);
369#endif 364#endif
370 memset(ctx, '\0', sizeof *ctx); 365 memset(ctx, 0, sizeof *ctx);
371 366
372 return 1; 367 return 1;
373} 368}