Fix possible usage of NULL pointers in apps/spkac.c
[openssl.git] / apps / req.c
index f1dba66041ab71863757df410e535a1db5bbca6f..a47dfcffafced7878c5661be1e4b0a0a1f186dd4 100644 (file)
@@ -288,7 +288,6 @@ int req_main(int argc, char **argv)
             break;
         case OPT_X509:
             x509 = 1;
-            newreq = 1;
             break;
         case OPT_DAYS:
             days = atoi(opt_arg());
@@ -331,6 +330,9 @@ int req_main(int argc, char **argv)
     if (argc != 0)
         goto opthelp;
 
+    if (x509 && infile == NULL)
+        newreq = 1;
+
     /* TODO: simplify this as pkey is still always NULL here */
     private = newreq && (pkey == NULL) ? 1 : 0;
 
@@ -582,7 +584,7 @@ int req_main(int argc, char **argv)
         }
     }
 
-    if (newreq) {
+    if (newreq || x509) {
         if (pkey == NULL) {
             BIO_printf(bio_err, "you need to specify a private key\n");
             goto end;