From: Dr. Stephen Henson Date: Thu, 11 Nov 2010 14:42:34 +0000 (+0000) Subject: PR: 2366 X-Git-Tag: OpenSSL_1_0_1-beta1~451 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=84fbc56fd05e9681857a9d1e8804e484e29acd84;p=oweals%2Fopenssl.git PR: 2366 Submitted by: Damien Miller Reviewed by: steve Stop pkeyutl crashing if some arguments are missing. Also make str2fmt tolerate NULL parameter. --- diff --git a/apps/apps.c b/apps/apps.c index 69d0c2d45a..c2797711ae 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -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')) diff --git a/apps/pkeyutl.c b/apps/pkeyutl.c index 22a6c4bf39..7eb3f5c544 100644 --- a/apps/pkeyutl.c +++ b/apps/pkeyutl.c @@ -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"))