From bb821237073753cd96af7b319ae00dea805a20a4 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Thu, 5 Aug 2004 18:10:46 +0000 Subject: [PATCH] Don't ignore return values of EVP_DigestInit_ex() in md BIOs and dgst. --- apps/dgst.c | 8 +++++++- crypto/evp/bio_md.c | 10 ++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/dgst.c b/apps/dgst.c index 8b4ec7f2e2..f8d9a70f23 100644 --- a/apps/dgst.c +++ b/apps/dgst.c @@ -330,7 +330,13 @@ int MAIN(int argc, char **argv) } /* we use md as a filter, reading from 'in' */ - BIO_set_md(bmd,md); + if (!BIO_set_md(bmd,md)) + { + BIO_printf(bio_err, "Error setting digest %s\n", pname); + ERR_print_errors(bio_err); + goto end; + } + inp=BIO_push(bmd,in); if (argc == 0) diff --git a/crypto/evp/bio_md.c b/crypto/evp/bio_md.c index 53f1f56cad..e4a4d663cb 100644 --- a/crypto/evp/bio_md.c +++ b/crypto/evp/bio_md.c @@ -176,10 +176,11 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr) { case BIO_CTRL_RESET: if (b->init) - EVP_DigestInit_ex(ctx,ctx->digest, NULL); + ret = EVP_DigestInit_ex(ctx,ctx->digest, NULL); else ret=0; - ret=BIO_ctrl(b->next_bio,cmd,num,ptr); + if (ret > 0) + ret=BIO_ctrl(b->next_bio,cmd,num,ptr); break; case BIO_C_GET_MD: if (b->init) @@ -213,8 +214,9 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr) case BIO_C_SET_MD: md=ptr; - EVP_DigestInit_ex(ctx,md, NULL); - b->init=1; + ret = EVP_DigestInit_ex(ctx,md, NULL); + if (ret > 0) + b->init=1; break; case BIO_CTRL_DUP: dbio=ptr; -- 2.25.1