提交 10b37541 编写于 作者: R Richard Levitte

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: NMatt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6051)
上级 14879629
...@@ -153,6 +153,11 @@ int dhparam_main(int argc, char **argv) ...@@ -153,6 +153,11 @@ int dhparam_main(int argc, char **argv)
goto end; goto end;
} }
# endif # endif
out = bio_open_default(outfile, 'w', outformat);
if (out == NULL)
goto end;
/* DH parameters */ /* DH parameters */
if (num && !g) if (num && !g)
g = 2; g = 2;
...@@ -260,10 +265,6 @@ int dhparam_main(int argc, char **argv) ...@@ -260,10 +265,6 @@ int dhparam_main(int argc, char **argv)
/* dh != NULL */ /* dh != NULL */
} }
out = bio_open_default(outfile, 'w', outformat);
if (out == NULL)
goto end;
if (text) { if (text) {
DHparams_print(out, dh); DHparams_print(out, dh);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册