Correctly handle case of bad arguments supplied to rsautl
authorLutz Jänicke <jaenicke@openssl.org>
Thu, 17 Apr 2008 13:36:13 +0000 (13:36 +0000)
committerLutz Jänicke <jaenicke@openssl.org>
Thu, 17 Apr 2008 13:36:13 +0000 (13:36 +0000)
PR: 1659

apps/rsautl.c

index 4638909..f3c458e 100644 (file)
@@ -119,24 +119,36 @@ int MAIN(int argc, char **argv)
        while(argc >= 1)
        {
                if (!strcmp(*argv,"-in")) {
-                       if (--argc < 1) badarg = 1;
-                        infile= *(++argv);
+                       if (--argc < 1)
+                               badarg = 1;
+                       else
+                               infile= *(++argv);
                } else if (!strcmp(*argv,"-out")) {
-                       if (--argc < 1) badarg = 1;
-                       outfile= *(++argv);
+                       if (--argc < 1)
+                               badarg = 1;
+                       else
+                               outfile= *(++argv);
                } else if(!strcmp(*argv, "-inkey")) {
-                       if (--argc < 1) badarg = 1;
-                       keyfile = *(++argv);
+                       if (--argc < 1)
+                               badarg = 1;
+                       else
+                               keyfile = *(++argv);
                } else if (!strcmp(*argv,"-passin")) {
-                       if (--argc < 1) badarg = 1;
-                       passargin= *(++argv);
+                       if (--argc < 1)
+                               badarg = 1;
+                       else
+                               passargin= *(++argv);
                } else if (strcmp(*argv,"-keyform") == 0) {
-                       if (--argc < 1) badarg = 1;
-                       keyform=str2fmt(*(++argv));
+                       if (--argc < 1)
+                               badarg = 1;
+                       else
+                               keyform=str2fmt(*(++argv));
 #ifndef OPENSSL_NO_ENGINE
                } else if(!strcmp(*argv, "-engine")) {
-                       if (--argc < 1) badarg = 1;
-                       engine = *(++argv);
+                       if (--argc < 1)
+                               badarg = 1;
+                       else
+                               engine = *(++argv);
 #endif
                } else if(!strcmp(*argv, "-pubin")) {
                        key_type = KEY_PUBKEY;