APPS: Fix invoking openssl without a command
authorSebastian Andrzej Siewior <sebastian@breakpoint.cc>
Sat, 6 Jun 2020 10:55:59 +0000 (12:55 +0200)
committerRichard Levitte <levitte@openssl.org>
Tue, 23 Jun 2020 10:23:02 +0000 (12:23 +0200)
Invoking help with "empty" argc leads to a segfault.
Invoke do_cmd() with help as argument which invokes help_main() with
proper argv.

Fixes #12069

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12070)

apps/openssl.c

index 4c97936824ca556138ee25fbd0d64999c913b5ec..fdf4a746f8096cdb35d6845d02c60bfde41e2b7e 100644 (file)
@@ -205,6 +205,8 @@ static void setup_trace(const char *str)
 }
 #endif /* OPENSSL_NO_TRACE */
 
+static char *help_argv[] = { "help" };
+
 int main(int argc, char *argv[])
 {
     FUNCTION f, *fp;
@@ -268,7 +270,7 @@ int main(int argc, char *argv[])
     /* If there's a command, run with that, otherwise "help". */
     ret = argc > 0
         ? do_cmd(prog, argc, argv)
-        : help_main(argc, argv);
+        : do_cmd(prog, 1, help_argv);
 
  end:
     app_providers_cleanup();