diff options
author | Richard Levitte <levitte@openssl.org> | 2016-12-07 16:36:44 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2016-12-08 00:06:43 +0100 |
commit | 0a687ab0a92d2d68289364a6e232028c229f44bb (patch) | |
tree | 840d4e1949a942b758fc9fd69ad7fef146ff0fb0 /crypto/ui/ui_lib.c | |
parent | 7cb58c0ffa7203e8ad4d39c912a1ab5e21a12b85 (diff) | |
download | openssl-0a687ab0a92d2d68289364a6e232028c229f44bb.tar.gz |
UI_process() didn't generate errors
Since there are many parts of UI_process() that can go wrong, it isn't
very helpful to only return -1 with no further explanation. With this
change, the error message will at least show which part went wrong.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2037)
Diffstat (limited to 'crypto/ui/ui_lib.c')
-rw-r--r-- | crypto/ui/ui_lib.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c index 273bfb6095..838175d815 100644 --- a/crypto/ui/ui_lib.c +++ b/crypto/ui/ui_lib.c @@ -427,9 +427,13 @@ static int print_error(const char *str, size_t len, UI *ui) int UI_process(UI *ui) { int i, ok = 0; + const char *state = "processing"; - if (ui->meth->ui_open_session && !ui->meth->ui_open_session(ui)) - return -1; + if (ui->meth->ui_open_session && !ui->meth->ui_open_session(ui)) { + state = "opening session"; + ok = -1; + goto err; + } if (ui->flags & UI_FLAG_PRINT_ERRORS) ERR_print_errors_cb((int (*)(const char *, size_t, void *)) @@ -440,6 +444,7 @@ int UI_process(UI *ui) && !ui->meth->ui_write_string(ui, sk_UI_STRING_value(ui->strings, i))) { + state = "writing strings"; ok = -1; goto err; } @@ -451,6 +456,7 @@ int UI_process(UI *ui) ok = -2; goto err; case 0: /* Errors */ + state = "flushing"; ok = -1; goto err; default: /* Success */ @@ -467,6 +473,7 @@ int UI_process(UI *ui) ok = -2; goto err; case 0: /* Errors */ + state = "reading strings"; ok = -1; goto err; default: /* Success */ @@ -476,8 +483,16 @@ int UI_process(UI *ui) } } err: - if (ui->meth->ui_close_session && !ui->meth->ui_close_session(ui)) - return -1; + if (ui->meth->ui_close_session && !ui->meth->ui_close_session(ui)) { + if (state == NULL) + state = "closing session"; + ok = -1; + } + + if (ok == -1) { + UIerr(UI_F_UI_PROCESS, UI_R_PROCESSING_ERROR); + ERR_add_error_data(2, "while ", state); + } return ok; } |