summaryrefslogtreecommitdiffstats
path: root/crypto/ui/ui_lib.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-11-04 16:14:00 +0100
committerRichard Levitte <levitte@openssl.org>2020-11-13 09:35:31 +0100
commita150f8e1fcc38752fef4d7c75d765d8efc7d46d6 (patch)
treef7f62c9a5d8407d8b17820fbef67378aa7b9ddbb /crypto/ui/ui_lib.c
parent9311d0c471ca2eaa259e8c1bbbeb7c46394c7ba2 (diff)
CRYPTO: refactor ERR_raise()+ERR_add_error_data() to ERR_raise_data()
This is not done absolutely everywhere, as there are places where the use of ERR_add_error_data() is quite complex, but at least the simple cases are done. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13318)
Diffstat (limited to 'crypto/ui/ui_lib.c')
-rw-r--r--crypto/ui/ui_lib.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c
index 4c74546612..fd03dc6cd0 100644
--- a/crypto/ui/ui_lib.c
+++ b/crypto/ui/ui_lib.c
@@ -540,10 +540,8 @@ int UI_process(UI *ui)
ok = -1;
}
- if (ok == -1) {
- ERR_raise(ERR_LIB_UI, UI_R_PROCESSING_ERROR);
- ERR_add_error_data(2, "while ", state);
- }
+ if (ok == -1)
+ ERR_raise_data(ERR_LIB_UI, UI_R_PROCESSING_ERROR, "while %s", state);
return ok;
}
@@ -881,29 +879,21 @@ int UI_set_result_ex(UI *ui, UI_STRING *uis, const char *result, int len)
switch (uis->type) {
case UIT_PROMPT:
case UIT_VERIFY:
- {
- char number1[DECIMAL_SIZE(uis->_.string_data.result_minsize) + 1];
- char number2[DECIMAL_SIZE(uis->_.string_data.result_maxsize) + 1];
-
- BIO_snprintf(number1, sizeof(number1), "%d",
- uis->_.string_data.result_minsize);
- BIO_snprintf(number2, sizeof(number2), "%d",
- uis->_.string_data.result_maxsize);
-
- if (len < uis->_.string_data.result_minsize) {
- ui->flags |= UI_FLAG_REDOABLE;
- ERR_raise(ERR_LIB_UI, UI_R_RESULT_TOO_SMALL);
- ERR_add_error_data(5, "You must type in ",
- number1, " to ", number2, " characters");
- return -1;
- }
- if (len > uis->_.string_data.result_maxsize) {
- ui->flags |= UI_FLAG_REDOABLE;
- ERR_raise(ERR_LIB_UI, UI_R_RESULT_TOO_LARGE);
- ERR_add_error_data(5, "You must type in ",
- number1, " to ", number2, " characters");
- return -1;
- }
+ if (len < uis->_.string_data.result_minsize) {
+ ui->flags |= UI_FLAG_REDOABLE;
+ ERR_raise_data(ERR_LIB_UI, UI_R_RESULT_TOO_SMALL,
+ "You must type in %d to %d characters",
+ uis->_.string_data.result_minsize,
+ uis->_.string_data.result_maxsize);
+ return -1;
+ }
+ if (len > uis->_.string_data.result_maxsize) {
+ ui->flags |= UI_FLAG_REDOABLE;
+ ERR_raise_data(ERR_LIB_UI, UI_R_RESULT_TOO_LARGE,
+ "You must type in %d to %d characters",
+ uis->_.string_data.result_minsize,
+ uis->_.string_data.result_maxsize);
+ return -1;
}
if (uis->result_buf == NULL) {