Skip to content

Commit

Permalink
Don't ignore return value of EVP_DigestInit_ex() in md BIOs and dgst …
Browse files Browse the repository at this point in the history
…utility.
  • Loading branch information
snhenson committed Aug 5, 2004
1 parent 30fe028 commit c128bb0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 7 additions & 1 deletion apps/dgst.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,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)
Expand Down
10 changes: 6 additions & 4 deletions crypto/evp/bio_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -207,8 +208,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;
Expand Down

0 comments on commit c128bb0

Please sign in to comment.