diff options
author | Richard Levitte <levitte@openssl.org> | 2018-04-23 10:26:05 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2018-04-23 10:51:36 +0200 |
commit | 10b37541dc7f27b0ca74102970691ce4636cc0bd (patch) | |
tree | 1878839e35a997a09eecebd699cd846d04ea907c /apps | |
parent | 148796291e47ad402ddfd1bbe6f34a2652657ec2 (diff) |
Fix late opening of output file
For 'openssl dhparams', the output file was opened after calculations
were made, which is a waste of cycles and time if the output file
turns out not to be writable.
Fixes #3404
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6051)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dhparam.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/apps/dhparam.c b/apps/dhparam.c index 8a3a389155..44160fde2b 100644 --- a/apps/dhparam.c +++ b/apps/dhparam.c @@ -153,6 +153,11 @@ int dhparam_main(int argc, char **argv) goto end; } # endif + + out = bio_open_default(outfile, 'w', outformat); + if (out == NULL) + goto end; + /* DH parameters */ if (num && !g) g = 2; @@ -260,10 +265,6 @@ int dhparam_main(int argc, char **argv) /* dh != NULL */ } - out = bio_open_default(outfile, 'w', outformat); - if (out == NULL) - goto end; - if (text) { DHparams_print(out, dh); } |