apps/dgst.c: Set digestname from argv[0] if it is a builtin hash name
authorTomas Mraz <tomas@openssl.org>
Fri, 4 Nov 2022 11:20:08 +0000 (12:20 +0100)
committerTomas Mraz <tomas@openssl.org>
Mon, 7 Nov 2022 13:40:09 +0000 (14:40 +0100)
Fixes #19589

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/19606)

apps/dgst.c

index b6363eb5345dd451a8de1dba18264b81fa4e71a1..cbd4b4e2bec367fac2a7a151d86283ef029dc22d 100644 (file)
@@ -114,6 +114,8 @@ int dgst_main(int argc, char **argv)
 
     buf = app_malloc(BUFSIZE, "I/O buffer");
     md = (EVP_MD *)EVP_get_digestbyname(argv[0]);
+    if (md != NULL)
+        digestname = argv[0];
 
     opt_set_unknown_name("digest");
     prog = opt_init(argc, argv, dgst_options);