PR: 2366
authorDr. Stephen Henson <steve@openssl.org>
Thu, 11 Nov 2010 14:42:50 +0000 (14:42 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Thu, 11 Nov 2010 14:42:50 +0000 (14:42 +0000)
Submitted by: Damien Miller <djm@mindrot.org>
Reviewed by: steve

Stop pkeyutl crashing if some arguments are missing. Also make str2fmt
tolerate NULL parameter.

apps/apps.c
apps/pkeyutl.c

index 3344d533b24b72696997b50478a9fc3b0468c7eb..57390d37ccfe227660481b1e3f13c08f18cd19a8 100644 (file)
@@ -257,6 +257,8 @@ int args_from_file(char *file, int *argc, char **argv[])
 
 int str2fmt(char *s)
        {
+       if (s == NULL)
+               return FORMAT_UNDEF;
        if      ((*s == 'D') || (*s == 'd'))
                return(FORMAT_ASN1);
        else if ((*s == 'T') || (*s == 't'))
index 22a6c4bf397fe9253d3d51cbf0874bc3be2c5764..7eb3f5c544ddd0a3c0b59ee8c7be54559376c70c 100644 (file)
@@ -119,17 +119,17 @@ int MAIN(int argc, char **argv)
                if (!strcmp(*argv,"-in"))
                        {
                        if (--argc < 1) badarg = 1;
-                        infile= *(++argv);
+                        else infile= *(++argv);
                        }
                else if (!strcmp(*argv,"-out"))
                        {
                        if (--argc < 1) badarg = 1;
-                       outfile= *(++argv);
+                       else outfile= *(++argv);
                        }
                else if (!strcmp(*argv,"-sigfile"))
                        {
                        if (--argc < 1) badarg = 1;
-                       sigfile= *(++argv);
+                       else sigfile= *(++argv);
                        }
                else if(!strcmp(*argv, "-inkey"))
                        {
@@ -159,17 +159,17 @@ int MAIN(int argc, char **argv)
                else if (!strcmp(*argv,"-passin"))
                        {
                        if (--argc < 1) badarg = 1;
-                       passargin= *(++argv);
+                       else passargin= *(++argv);
                        }
                else if (strcmp(*argv,"-peerform") == 0)
                        {
                        if (--argc < 1) badarg = 1;
-                       peerform=str2fmt(*(++argv));
+                       else peerform=str2fmt(*(++argv));
                        }
                else if (strcmp(*argv,"-keyform") == 0)
                        {
                        if (--argc < 1) badarg = 1;
-                       keyform=str2fmt(*(++argv));
+                       else keyform=str2fmt(*(++argv));
                        }
 #ifndef OPENSSL_NO_ENGINE
                else if(!strcmp(*argv, "-engine"))