diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/usr.bin/openssl/ts.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/usr.bin/openssl/ts.c b/src/usr.bin/openssl/ts.c index c62f1dd6b5..dfcf5dd923 100644 --- a/src/usr.bin/openssl/ts.c +++ b/src/usr.bin/openssl/ts.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ts.c,v 1.27 2023/11/19 09:19:54 tb Exp $ */ | 1 | /* $OpenBSD: ts.c,v 1.28 2024/03/25 10:16:02 tb Exp $ */ |
| 2 | /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL | 2 | /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL |
| 3 | * project 2002. | 3 | * project 2002. |
| 4 | */ | 4 | */ |
| @@ -676,10 +676,12 @@ create_query(BIO *data_bio, char *digest, const EVP_MD *md, const char *policy, | |||
| 676 | 676 | ||
| 677 | static int | 677 | static int |
| 678 | create_digest(BIO *input, char *digest, const EVP_MD *md, | 678 | create_digest(BIO *input, char *digest, const EVP_MD *md, |
| 679 | unsigned char **md_value) | 679 | unsigned char **out_md_value) |
| 680 | { | 680 | { |
| 681 | int md_value_len; | ||
| 682 | EVP_MD_CTX *md_ctx = NULL; | 681 | EVP_MD_CTX *md_ctx = NULL; |
| 682 | unsigned char *md_value = NULL; | ||
| 683 | int md_value_len; | ||
| 684 | int ret = 0; | ||
| 683 | 685 | ||
| 684 | md_value_len = EVP_MD_size(md); | 686 | md_value_len = EVP_MD_size(md); |
| 685 | if (md_value_len < 0) | 687 | if (md_value_len < 0) |
| @@ -690,8 +692,8 @@ create_digest(BIO *input, char *digest, const EVP_MD *md, | |||
| 690 | unsigned char buffer[4096]; | 692 | unsigned char buffer[4096]; |
| 691 | int length; | 693 | int length; |
| 692 | 694 | ||
| 693 | *md_value = malloc(md_value_len); | 695 | md_value = malloc(md_value_len); |
| 694 | if (*md_value == NULL) | 696 | if (md_value == NULL) |
| 695 | goto err; | 697 | goto err; |
| 696 | 698 | ||
| 697 | if ((md_ctx = EVP_MD_CTX_new()) == NULL) | 699 | if ((md_ctx = EVP_MD_CTX_new()) == NULL) |
| @@ -705,31 +707,30 @@ create_digest(BIO *input, char *digest, const EVP_MD *md, | |||
| 705 | goto err; | 707 | goto err; |
| 706 | } | 708 | } |
| 707 | 709 | ||
| 708 | if (!EVP_DigestFinal(md_ctx, *md_value, NULL)) | 710 | if (!EVP_DigestFinal(md_ctx, md_value, NULL)) |
| 709 | goto err; | 711 | goto err; |
| 710 | |||
| 711 | EVP_MD_CTX_free(md_ctx); | ||
| 712 | md_ctx = NULL; | ||
| 713 | |||
| 714 | } else { | 712 | } else { |
| 715 | /* Digest bytes are specified with digest. */ | 713 | /* Digest bytes are specified with digest. */ |
| 716 | long digest_len; | 714 | long digest_len; |
| 717 | 715 | ||
| 718 | *md_value = string_to_hex(digest, &digest_len); | 716 | md_value = string_to_hex(digest, &digest_len); |
| 719 | if (*md_value == NULL || md_value_len != digest_len) { | 717 | if (md_value == NULL || md_value_len != digest_len) { |
| 720 | free(*md_value); | ||
| 721 | *md_value = NULL; | ||
| 722 | BIO_printf(bio_err, "bad digest, %d bytes " | 718 | BIO_printf(bio_err, "bad digest, %d bytes " |
| 723 | "must be specified\n", md_value_len); | 719 | "must be specified\n", md_value_len); |
| 724 | goto err; | 720 | goto err; |
| 725 | } | 721 | } |
| 726 | } | 722 | } |
| 727 | 723 | ||
| 728 | return md_value_len; | 724 | *out_md_value = md_value; |
| 725 | md_value = NULL; | ||
| 726 | |||
| 727 | ret = md_value_len; | ||
| 729 | 728 | ||
| 730 | err: | 729 | err: |
| 730 | free(md_value); | ||
| 731 | EVP_MD_CTX_free(md_ctx); | 731 | EVP_MD_CTX_free(md_ctx); |
| 732 | return 0; | 732 | |
| 733 | return ret; | ||
| 733 | } | 734 | } |
| 734 | 735 | ||
| 735 | static ASN1_INTEGER * | 736 | static ASN1_INTEGER * |
