diff options
author | jsing <> | 2014-06-15 15:46:22 +0000 |
---|---|---|
committer | jsing <> | 2014-06-15 15:46:22 +0000 |
commit | 9f854fb85a6b6747c90f31c5816701dfdb8769a9 (patch) | |
tree | d2c2643cbaff4a68a03c97ee70dbb6e694b3c3a7 /src | |
parent | 38a8ba4b0cb305320f7f52da8803cb7415a1b19e (diff) | |
download | openbsd-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.c | 13 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/evp/digest.c | 13 |
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 @@ | |||
120 | void | 120 | void |
121 | EVP_MD_CTX_init(EVP_MD_CTX *ctx) | 121 | EVP_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 | ||
126 | EVP_MD_CTX * | 126 | EVP_MD_CTX * |
127 | EVP_MD_CTX_create(void) | 127 | EVP_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 | ||
137 | int | 132 | int |
@@ -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 @@ | |||
120 | void | 120 | void |
121 | EVP_MD_CTX_init(EVP_MD_CTX *ctx) | 121 | EVP_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 | ||
126 | EVP_MD_CTX * | 126 | EVP_MD_CTX * |
127 | EVP_MD_CTX_create(void) | 127 | EVP_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 | ||
137 | int | 132 | int |
@@ -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 | } |