X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=apps%2Fsmime.c;h=4da56cdf08cccddb1e940231b1c26d788eefe5eb;hp=e544ca216125f26bf2f6b20794205402beadf09e;hb=bdd58d98467e9f0f6635c1628e1eae304383afb1;hpb=25aaa98aa249d26391c1994d2de449562c8b8b99 diff --git a/apps/smime.c b/apps/smime.c index e544ca2161..4da56cdf08 100644 --- a/apps/smime.c +++ b/apps/smime.c @@ -170,7 +170,6 @@ int smime_main(int argc, char **argv) NULL; char *passinarg = NULL, *passin = NULL, *to = NULL, *from = NULL, *subject = NULL; - const char *inmode = "r", *outmode = "w"; OPTION_CHOICE o; int flags = PKCS7_DETACHED, operation = 0, ret = 0, need_rand = 0, indef = 0; @@ -411,6 +410,9 @@ int smime_main(int argc, char **argv) goto end; } + if (!app_load_modules(NULL)) + goto end; + if (need_rand) { app_RAND_load_file(NULL, (inrand != NULL)); if (inrand != NULL) @@ -423,20 +425,14 @@ int smime_main(int argc, char **argv) if (!(operation & SMIME_SIGNERS)) flags &= ~PKCS7_DETACHED; - if (operation & SMIME_OP) { - if (outformat == FORMAT_ASN1) - outmode = "wb"; - } else { + if (!(operation & SMIME_OP)) { if (flags & PKCS7_BINARY) - outmode = "wb"; + outformat = FORMAT_BINARY; } - if (operation & SMIME_IP) { - if (informat == FORMAT_ASN1) - inmode = "rb"; - } else { + if (!(operation & SMIME_IP)) { if (flags & PKCS7_BINARY) - inmode = "rb"; + informat = FORMAT_BINARY; } if (operation == SMIME_ENCRYPT) { @@ -463,16 +459,16 @@ int smime_main(int argc, char **argv) } if (certfile) { - if (!(other = load_certs(certfile, FORMAT_PEM, NULL, - e, "certificate file"))) { + if ((other = load_certs(certfile, FORMAT_PEM, NULL, + e, "certificate file")) == NULL) { ERR_print_errors(bio_err); goto end; } } if (recipfile && (operation == SMIME_DECRYPT)) { - if (!(recip = load_cert(recipfile, FORMAT_PEM, NULL, - e, "recipient certificate file"))) { + if ((recip = load_cert(recipfile, FORMAT_PEM, NULL, + e, "recipient certificate file")) == NULL) { ERR_print_errors(bio_err); goto end; } @@ -493,7 +489,7 @@ int smime_main(int argc, char **argv) goto end; } - in = bio_open_default(infile, inmode); + in = bio_open_default(infile, 'r', informat); if (in == NULL) goto end; @@ -515,19 +511,19 @@ int smime_main(int argc, char **argv) } if (contfile) { BIO_free(indata); - if (!(indata = BIO_new_file(contfile, "rb"))) { + if ((indata = BIO_new_file(contfile, "rb")) == NULL) { BIO_printf(bio_err, "Can't read content file %s\n", contfile); goto end; } } } - out = bio_open_default(outfile, outmode); + out = bio_open_default(outfile, 'w', outformat); if (out == NULL) goto end; if (operation == SMIME_VERIFY) { - if (!(store = setup_verify(CAfile, CApath))) + if ((store = setup_verify(CAfile, CApath)) == NULL) goto end; X509_STORE_set_verify_cb(store, smime_cb); if (vpmtouched)