Submitted by: Damien Miller <djm@mindrot.org>
Reviewed by: steve

Stop pkeyutl crashing if some arguments are missing. Also make str2fmt
tolerate NULL parameter.
This commit is contained in:
Dr. Stephen Henson 2010-11-11 14:42:19 +00:00
parent 0af0e9d747
commit 6806b06d21
2 changed files with 8 additions and 6 deletions

View file

@ -257,6 +257,8 @@ int args_from_file(char *file, int *argc, char **argv[])
int str2fmt(char *s) int str2fmt(char *s)
{ {
if (s == NULL)
return FORMAT_UNDEF;
if ((*s == 'D') || (*s == 'd')) if ((*s == 'D') || (*s == 'd'))
return(FORMAT_ASN1); return(FORMAT_ASN1);
else if ((*s == 'T') || (*s == 't')) else if ((*s == 'T') || (*s == 't'))

View file

@ -119,17 +119,17 @@ int MAIN(int argc, char **argv)
if (!strcmp(*argv,"-in")) if (!strcmp(*argv,"-in"))
{ {
if (--argc < 1) badarg = 1; if (--argc < 1) badarg = 1;
infile= *(++argv); else infile= *(++argv);
} }
else if (!strcmp(*argv,"-out")) else if (!strcmp(*argv,"-out"))
{ {
if (--argc < 1) badarg = 1; if (--argc < 1) badarg = 1;
outfile= *(++argv); else outfile= *(++argv);
} }
else if (!strcmp(*argv,"-sigfile")) else if (!strcmp(*argv,"-sigfile"))
{ {
if (--argc < 1) badarg = 1; if (--argc < 1) badarg = 1;
sigfile= *(++argv); else sigfile= *(++argv);
} }
else if(!strcmp(*argv, "-inkey")) else if(!strcmp(*argv, "-inkey"))
{ {
@ -159,17 +159,17 @@ int MAIN(int argc, char **argv)
else if (!strcmp(*argv,"-passin")) else if (!strcmp(*argv,"-passin"))
{ {
if (--argc < 1) badarg = 1; if (--argc < 1) badarg = 1;
passargin= *(++argv); else passargin= *(++argv);
} }
else if (strcmp(*argv,"-peerform") == 0) else if (strcmp(*argv,"-peerform") == 0)
{ {
if (--argc < 1) badarg = 1; if (--argc < 1) badarg = 1;
peerform=str2fmt(*(++argv)); else peerform=str2fmt(*(++argv));
} }
else if (strcmp(*argv,"-keyform") == 0) else if (strcmp(*argv,"-keyform") == 0)
{ {
if (--argc < 1) badarg = 1; if (--argc < 1) badarg = 1;
keyform=str2fmt(*(++argv)); else keyform=str2fmt(*(++argv));
} }
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
else if(!strcmp(*argv, "-engine")) else if(!strcmp(*argv, "-engine"))