diff options
author | Richard Levitte <levitte@openssl.org> | 2015-09-04 12:49:06 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2015-09-06 01:35:54 +0200 |
commit | bdd58d98467e9f0f6635c1628e1eae304383afb1 (patch) | |
tree | 1927fc4a65f8fd8b5705c5c5e0278beabf2c2b28 /apps/apps.c | |
parent | d303b9d85e1888494785f87ebd9bd233e63564a9 (diff) | |
download | openssl-bdd58d98467e9f0f6635c1628e1eae304383afb1.tar.gz |
Change the way apps open their input and output files
The different apps had the liberty to decide whether they would open their
input and output files in binary mode or not, which could be confusing if
two different apps were handling the same type of file in different ways.
The solution is to centralise the decision of low level file organisation,
and that the apps would use a selection of formats to state the intent of
the file.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'apps/apps.c')
-rw-r--r-- | apps/apps.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/apps/apps.c b/apps/apps.c index 80e777774f..f3b2d48f3a 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -514,7 +514,7 @@ CONF *app_load_config(const char *filename) BIO *in; CONF *conf; - in = bio_open_default(filename, "r"); + in = bio_open_default(filename, 'r', FORMAT_TEXT); if (in == NULL) return NULL; @@ -527,7 +527,7 @@ CONF *app_load_config_quiet(const char *filename) BIO *in; CONF *conf; - in = bio_open_default_quiet(filename, "r"); + in = bio_open_default_quiet(filename, 'r', FORMAT_TEXT); if (in == NULL) return NULL; @@ -683,7 +683,7 @@ X509 *load_cert(const char *file, int format, unbuffer(stdin); cert = dup_bio_in(); } else - cert = bio_open_default(file, RB(format)); + cert = bio_open_default(file, 'r', format); if (cert == NULL) goto end; @@ -718,7 +718,7 @@ X509_CRL *load_crl(const char *infile, int format) return x; } - in = bio_open_default(infile, RB(format)); + in = bio_open_default(infile, 'r', format); if (in == NULL) goto end; if (format == FORMAT_ASN1) @@ -772,7 +772,7 @@ EVP_PKEY *load_key(const char *file, int format, int maybe_stdin, unbuffer(stdin); key = dup_bio_in(); } else - key = bio_open_default(file, RB(format)); + key = bio_open_default(file, 'r', format); if (key == NULL) goto end; if (format == FORMAT_ASN1) { @@ -808,13 +808,6 @@ EVP_PKEY *load_key(const char *file, int format, int maybe_stdin, return (pkey); } -static const char *key_file_format(int format) -{ - if (format == FORMAT_PEM || format == FORMAT_PEMRSA) - return "r"; - return "rb"; -} - EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin, const char *pass, ENGINE *e, const char *key_descrip) { @@ -842,7 +835,7 @@ EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin, unbuffer(stdin); key = dup_bio_in(); } else - key = bio_open_default(file, key_file_format(format)); + key = bio_open_default(file, 'r', format); if (key == NULL) goto end; if (format == FORMAT_ASN1) { @@ -909,7 +902,7 @@ static int load_certs_crls(const char *file, int format, return 0; } - bio = bio_open_default(file, "r"); + bio = bio_open_default(file, 'r', FORMAT_PEM); if (bio == NULL) return 0; |