make depend
[openssl.git] / apps / engine.c
index 7dcc1b0817ad809094644a7ac628b1d0427b595a..b1c13715287831aae676e8537ab57a87ca106dfb 100644 (file)
@@ -98,9 +98,7 @@ static int append_buf(char **buf, const char *s, int *size, int step)
 
     if (*buf == NULL) {
         *size = step;
-        *buf = OPENSSL_malloc(*size);
-        if (*buf == NULL)
-            return 0;
+        *buf = app_malloc(*size, "engine buffer");
         **buf = '\0';
     }
 
@@ -211,8 +209,7 @@ static int util_verbose(ENGINE *e, int verbose, BIO *out, const char *indent)
             if ((len = ENGINE_ctrl(e, ENGINE_CTRL_GET_NAME_LEN_FROM_CMD, num,
                                    NULL, NULL)) <= 0)
                 goto err;
-            if ((name = OPENSSL_malloc(len + 1)) == NULL)
-                goto err;
+            name = app_malloc(len + 1, "name buffer");
             if (ENGINE_ctrl(e, ENGINE_CTRL_GET_NAME_FROM_CMD, num, name,
                             NULL) <= 0)
                 goto err;
@@ -221,8 +218,7 @@ static int util_verbose(ENGINE *e, int verbose, BIO *out, const char *indent)
                                    NULL, NULL)) < 0)
                 goto err;
             if (len > 0) {
-                if ((desc = OPENSSL_malloc(len + 1)) == NULL)
-                    goto err;
+                desc = app_malloc(len + 1, "description buffer");
                 if (ENGINE_ctrl(e, ENGINE_CTRL_GET_DESC_FROM_CMD, num, desc,
                                 NULL) <= 0)
                     goto err;
@@ -256,10 +252,8 @@ static int util_verbose(ENGINE *e, int verbose, BIO *out, const char *indent)
         }
         OPENSSL_free(name);
         name = NULL;
-        if (desc) {
-            OPENSSL_free(desc);
-            desc = NULL;
-        }
+        OPENSSL_free(desc);
+        desc = NULL;
         /* Move to the next command */
         num = ENGINE_ctrl(e, ENGINE_CTRL_GET_NEXT_CMD_TYPE, num, NULL, NULL);
     } while (num > 0);
@@ -267,12 +261,9 @@ static int util_verbose(ENGINE *e, int verbose, BIO *out, const char *indent)
         BIO_printf(out, "\n");
     ret = 1;
  err:
-    if (cmds)
-        sk_OPENSSL_STRING_pop_free(cmds, identity);
-    if (name)
-        OPENSSL_free(name);
-    if (desc)
-        OPENSSL_free(desc);
+    sk_OPENSSL_STRING_pop_free(cmds, identity);
+    OPENSSL_free(name);
+    OPENSSL_free(desc);
     return ret;
 }
 
@@ -328,7 +319,7 @@ int engine_main(int argc, char **argv)
     OPTION_CHOICE o;
     char *prog;
 
-    out = dup_bio_out();
+    out = dup_bio_out(FORMAT_TEXT);
     prog = opt_init(argc, argv, engine_options);
     if (!engines || !pre_cmds || !post_cmds)
         goto end;
@@ -378,6 +369,9 @@ int engine_main(int argc, char **argv)
         }
     }
 
+    if (!app_load_modules(NULL))
+        goto end;
+
     for (i = 0; i < sk_OPENSSL_STRING_num(engines); i++) {
         const char *id = sk_OPENSSL_STRING_value(engines, i);
         if ((e = ENGINE_by_id(id)) != NULL) {