diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2021-01-21 12:36:58 +0100 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2021-02-22 08:49:52 +0100 |
commit | 7f90026b3fca9cfd3d9098d358d949d37509a2e5 (patch) | |
tree | d91a6f22702f8977560f7ffec75ac0e10e942bc9 /apps | |
parent | 4718326a46ad460fefc5cc240a8599af4b5993c7 (diff) | |
download | openssl-7f90026b3fca9cfd3d9098d358d949d37509a2e5.tar.gz |
Handle NULL result of ERR_reason_error_string() in some apps
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13920)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/pkey.c | 11 | ||||
-rw-r--r-- | apps/pkeyparam.c | 10 | ||||
-rw-r--r-- | apps/rsa.c | 13 |
3 files changed, 7 insertions, 27 deletions
diff --git a/apps/pkey.c b/apps/pkey.c index 1a53447401..5cf0abe04b 100644 --- a/apps/pkey.c +++ b/apps/pkey.c @@ -258,15 +258,8 @@ int pkey_main(int argc, char **argv) * Note: at least for RSA keys if this function returns * -1, there will be no error reasons. */ - unsigned long err; - - BIO_printf(out, "Key is invalid\n"); - - while ((err = ERR_peek_error()) != 0) { - BIO_printf(out, "Detailed error: %s\n", - ERR_reason_error_string(err)); - ERR_get_error(); /* remove err from error stack */ - } + BIO_printf(bio_err, "Key is invalid\n"); + ERR_print_errors(bio_err); goto end; } } diff --git a/apps/pkeyparam.c b/apps/pkeyparam.c index 42de552753..ef1a082d62 100644 --- a/apps/pkeyparam.c +++ b/apps/pkeyparam.c @@ -52,7 +52,6 @@ int pkeyparam_main(int argc, char **argv) int text = 0, noout = 0, ret = EXIT_FAILURE, check = 0, r; OPTION_CHOICE o; char *infile = NULL, *outfile = NULL, *prog; - unsigned long err; prog = opt_init(argc, argv, pkeyparam_options); while ((o = opt_next()) != OPT_EOF) { @@ -125,13 +124,8 @@ int pkeyparam_main(int argc, char **argv) * Note: at least for RSA keys if this function returns * -1, there will be no error reasons. */ - BIO_printf(out, "Parameters are invalid\n"); - - while ((err = ERR_peek_error()) != 0) { - BIO_printf(out, "Detailed error: %s\n", - ERR_reason_error_string(err)); - ERR_get_error(); /* remove err from error stack */ - } + BIO_printf(bio_err, "Parameters are invalid\n"); + ERR_print_errors(bio_err); goto end; } } diff --git a/apps/rsa.c b/apps/rsa.c index 499013bae4..251f84f210 100644 --- a/apps/rsa.c +++ b/apps/rsa.c @@ -259,7 +259,7 @@ int rsa_main(int argc, char **argv) pctx = EVP_PKEY_CTX_new_from_pkey(NULL, pkey, NULL); if (pctx == NULL) { - BIO_printf(out, "RSA unable to create PKEY context\n"); + BIO_printf(bio_err, "RSA unable to create PKEY context\n"); ERR_print_errors(bio_err); goto end; } @@ -269,15 +269,8 @@ int rsa_main(int argc, char **argv) if (r == 1) { BIO_printf(out, "RSA key ok\n"); } else if (r == 0) { - unsigned long err; - - while ((err = ERR_peek_error()) != 0 && - ERR_GET_LIB(err) == ERR_LIB_RSA && - ERR_GET_REASON(err) != ERR_R_MALLOC_FAILURE) { - BIO_printf(out, "RSA key error: %s\n", - ERR_reason_error_string(err)); - ERR_get_error(); /* remove err from error stack */ - } + BIO_printf(bio_err, "RSA key not ok\n"); + ERR_print_errors(bio_err); } else if (r == -1) { ERR_print_errors(bio_err); goto end; |