RT2943: Check sizes if -iv and -K arguments
[openssl.git] / apps / dhparam.c
index e842ca5f20ed5cb5a99a5addba2ca1cbe9a5afac..c66c5916cf9748a0eb5bada7e489c96394c2743c 100644 (file)
@@ -167,8 +167,7 @@ int dhparam_main(int argc, char **argv)
 {
     BIO *in = NULL, *out = NULL;
     DH *dh = NULL;
-    char *engine = NULL, *infile = NULL, *outfile = NULL, *prog, *inrand =
-        NULL;
+    char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL;
     int dsaparam = 0, i, text = 0, C = 0, ret = 1, num = 0, g = 0;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM, check = 0, noout = 0;
     OPTION_CHOICE o;
@@ -200,7 +199,7 @@ int dhparam_main(int argc, char **argv)
             outfile = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            (void)setup_engine(opt_arg(), 0);
             break;
         case OPT_CHECK:
             check = 1;
@@ -234,10 +233,6 @@ int dhparam_main(int argc, char **argv)
     if (argv[0] && (!opt_int(argv[0], &num) || num <= 0))
         goto end;
 
-# ifndef OPENSSL_NO_ENGINE
-    setup_engine(engine, 0);
-# endif
-
     if (g && !num)
         num = DEFBITS;
 
@@ -384,11 +379,7 @@ int dhparam_main(int argc, char **argv)
 
         len = BN_num_bytes(dh->p);
         bits = BN_num_bits(dh->p);
-        data = (unsigned char *)OPENSSL_malloc(len);
-        if (data == NULL) {
-            perror("OPENSSL_malloc");
-            goto end;
-        }
+        data = app_malloc(len, "print a BN");
         BIO_printf(out, "#ifndef HEADER_DH_H\n"
                         "# include <openssl/dh.h>\n"
                         "#endif\n"