PR: 2908
[oweals/openssl.git] / apps / engine.c
index 1a22d5dee9224df23e7e5cc79c02040c85eae08c..17bd81fb79bff3f14164678e80fb36a4897c6e22 100644 (file)
@@ -56,6 +56,7 @@
  *
  */
 
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #endif
 #include "apps.h"
 #include <openssl/err.h>
+#ifndef OPENSSL_NO_ENGINE
 #include <openssl/engine.h>
 #include <openssl/ssl.h>
 
 #undef PROG
 #define PROG   engine_main
 
-static char *engine_usage[]={
+static const char *engine_usage[]={
 "usage: engine opts [engine ...]\n",
 " -v[v[v[v]]] - verbose mode, for each engine, list its 'control commands'\n",
 "               -vv will additionally display each command's description\n",
@@ -121,8 +123,8 @@ static int append_buf(char **buf, const char *s, int *size, int step)
                return 0;
 
        if (**buf != '\0')
-               strcat(*buf, ", ");
-       strcat(*buf, s);
+               BUF_strlcat(*buf, ", ", *size);
+       BUF_strlcat(*buf, s, *size);
 
        return 1;
        }
@@ -250,7 +252,7 @@ static int util_verbose(ENGINE *e, int verbose, BIO *bio_out, const char *indent
                         /* Now decide on the output */
                         if(xpos == 0)
                                 /* Do an indent */
-                                xpos = BIO_printf(bio_out, indent);
+                                xpos = BIO_puts(bio_out, indent);
                         else
                                 /* Otherwise prepend a ", " */
                                 xpos += BIO_printf(bio_out, ", ");
@@ -261,7 +263,7 @@ static int util_verbose(ENGINE *e, int verbose, BIO *bio_out, const char *indent
                                        (xpos + (int)strlen(name) > line_wrap))
                                         {
                                         BIO_printf(bio_out, "\n");
-                                        xpos = BIO_printf(bio_out, indent);
+                                        xpos = BIO_puts(bio_out, indent);
                                         }
                                 xpos += BIO_printf(bio_out, "%s", name);
                                 }
@@ -342,7 +344,7 @@ int MAIN(int, char **);
 int MAIN(int argc, char **argv)
        {
        int ret=1,i;
-       char **pp;
+       const char **pp;
        int verbose=0, list_cap=0, test_avail=0, test_avail_noise = 0;
        ENGINE *e;
        STACK *engines = sk_new_null();
@@ -392,11 +394,15 @@ int MAIN(int argc, char **argv)
                else if (strcmp(*argv,"-pre") == 0)
                        {
                        argc--; argv++;
+                       if (argc == 0)
+                               goto skip_arg_loop;
                        sk_push(pre_cmds,*argv);
                        }
                else if (strcmp(*argv,"-post") == 0)
                        {
                        argc--; argv++;
+                       if (argc == 0)
+                               goto skip_arg_loop;
                        sk_push(post_cmds,*argv);
                        }
                else if ((strncmp(*argv,"-h",2) == 0) ||
@@ -518,6 +524,7 @@ skip_digests:
 
        ret=0;
 end:
+
        ERR_print_errors(bio_err);
        sk_pop_free(engines, identity);
        sk_pop_free(pre_cmds, identity);
@@ -526,3 +533,10 @@ end:
        apps_shutdown();
        OPENSSL_EXIT(ret);
        }
+#else
+
+# if PEDANTIC
+static void *dummy=&dummy;
+# endif
+
+#endif