diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2004-11-27 12:55:26 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2004-11-27 12:55:26 +0000 |
commit | 18ad97bbe710ec8a3bd89f45ea7f2edb76fdce50 (patch) | |
tree | d200a06c5300c3ac88644d05ce4a4d20b51efa35 /apps | |
parent | ee3f520276f1189d4ad091fd61413094437b661d (diff) | |
download | openssl-18ad97bbe710ec8a3bd89f45ea7f2edb76fdce50.tar.gz |
Fix leaks and give an error if no argument specified in prime.c
Diffstat (limited to 'apps')
-rw-r--r-- | apps/prime.c | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/apps/prime.c b/apps/prime.c index 5c731a7e01..5e3333bc4a 100644 --- a/apps/prime.c +++ b/apps/prime.c @@ -69,18 +69,6 @@ int MAIN(int argc, char **argv) if ((bio_err=BIO_new(BIO_s_file())) != NULL) BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); - if (bio_out == NULL) - if ((bio_out=BIO_new(BIO_s_file())) != NULL) - { - BIO_set_fp(bio_out,stdout,BIO_NOCLOSE); -#ifdef OPENSSL_SYS_VMS - { - BIO *tmpbio = BIO_new(BIO_f_linebuffer()); - bio_out = BIO_push(tmpbio, bio_out); - } -#endif - } - --argc; ++argv; while (argc >= 1 && **argv == '-') @@ -95,16 +83,30 @@ int MAIN(int argc, char **argv) else { BIO_printf(bio_err,"Unknown option '%s'\n",*argv); - bad: - BIO_printf(bio_err,"options are\n"); - BIO_printf(bio_err,"%-14s hex\n","-hex"); - BIO_printf(bio_err,"%-14s number of checks\n","-checks <n>"); - exit(1); + goto bad; } --argc; ++argv; } + if (argv[0] == NULL) + { + BIO_printf(bio_err,"No prime specified\n"); + goto bad; + } + + if (bio_out == NULL) + if ((bio_out=BIO_new(BIO_s_file())) != NULL) + { + BIO_set_fp(bio_out,stdout,BIO_NOCLOSE); +#ifdef OPENSSL_SYS_VMS + { + BIO *tmpbio = BIO_new(BIO_f_linebuffer()); + bio_out = BIO_push(tmpbio, bio_out); + } +#endif + } + if(hex) BN_hex2bn(&bn,argv[0]); else @@ -114,5 +116,14 @@ int MAIN(int argc, char **argv) BIO_printf(bio_out," is %sprime\n", BN_is_prime(bn,checks,NULL,NULL,NULL) ? "" : "not "); + BN_free(bn); + BIO_free(bio_out); + return 0; + + bad: + BIO_printf(bio_err,"options are\n"); + BIO_printf(bio_err,"%-14s hex\n","-hex"); + BIO_printf(bio_err,"%-14s number of checks\n","-checks <n>"); + exit(1); } |