Check # of arguments for remaining commands.
[openssl.git] / apps / prime.c
index 3c72330c0a62ac9e6973885c02e88663546a97df..9aa32d02b07296ce121caa73444b379b97ac0ed6 100644 (file)
@@ -43,6 +43,7 @@ int prime_main(int argc, char **argv)
         switch (o) {
         case OPT_EOF:
         case OPT_ERR:
+opthelp:
             BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
             goto end;
         case OPT_HELP:
@@ -69,9 +70,14 @@ int prime_main(int argc, char **argv)
     argc = opt_num_rest();
     argv = opt_rest();
 
-    if (argc == 0 && !generate) {
+    if (generate) {
+        if (argc != 0) {
+            BIO_printf(bio_err, "Extra arguments given.\n");
+            goto opthelp;
+        }
+    } else if (argc == 0) {
         BIO_printf(bio_err, "%s: No prime specified\n", prog);
-        goto end;
+        goto opthelp;
     }
 
     if (generate) {