Make ts.c compile with opaque EVP_MD_CTX.
authortb <tb@openbsd.org>
Sun, 12 Dec 2021 20:22:08 +0000 (20:22 +0000)
committertb <tb@openbsd.org>
Sun, 12 Dec 2021 20:22:08 +0000 (20:22 +0000)
ok inoguchi

usr.bin/openssl/ts.c

index cac10d0..9ac3aca 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ts.c,v 1.15 2018/02/07 05:47:55 jsing Exp $ */
+/* $OpenBSD: ts.c,v 1.16 2021/12/12 20:22:08 tb Exp $ */
 /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
  * project 2002.
  */
@@ -547,7 +547,7 @@ create_digest(BIO * input, char *digest, const EVP_MD * md,
                goto err;
        if (input) {
                /* Digest must be computed from an input file. */
-               EVP_MD_CTX md_ctx;
+               EVP_MD_CTX *md_ctx;
                unsigned char buffer[4096];
                int length;
 
@@ -555,11 +555,16 @@ create_digest(BIO * input, char *digest, const EVP_MD * md,
                if (*md_value == 0)
                        goto err;
 
-               EVP_DigestInit(&md_ctx, md);
+               if ((md_ctx = EVP_MD_CTX_new()) == NULL)
+                       goto err;
+
+               EVP_DigestInit(md_ctx, md);
                while ((length = BIO_read(input, buffer, sizeof(buffer))) > 0) {
-                       EVP_DigestUpdate(&md_ctx, buffer, length);
+                       EVP_DigestUpdate(md_ctx, buffer, length);
                }
-               EVP_DigestFinal(&md_ctx, *md_value, NULL);
+               EVP_DigestFinal(md_ctx, *md_value, NULL);
+
+               EVP_MD_CTX_free(md_ctx);
        } else {
                /* Digest bytes are specified with digest. */
                long digest_len;