summaryrefslogtreecommitdiffstats
path: root/lib/libssl/src/crypto/ui/ui_lib.c
diff options
context:
space:
mode:
authorbeck <beck@openbsd.org>2014-04-26 18:56:37 +0000
committerbeck <beck@openbsd.org>2014-04-26 18:56:37 +0000
commit0f637b92bc02cf08d6ec14891d27a582cbd971ae (patch)
tree86c57b804d6bfaf4c846d7c286917d8063f541d2 /lib/libssl/src/crypto/ui/ui_lib.c
parentsync (diff)
downloadwireguard-openbsd-0f637b92bc02cf08d6ec14891d27a582cbd971ae.tar.xz
wireguard-openbsd-0f637b92bc02cf08d6ec14891d27a582cbd971ae.zip
Replace all use of ERR_add_error_data with ERR_asprintf_error_data.
This avoids a lot of ugly gymnastics to do snprintfs before sending the bag of strings to ERR, and eliminates at least one place in dso_dlfctn.c where it was being called with the incorrect number of arguments and using random things off the stack as addresses of strings. ok krw@, jsing@
Diffstat (limited to 'lib/libssl/src/crypto/ui/ui_lib.c')
-rw-r--r--lib/libssl/src/crypto/ui/ui_lib.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/lib/libssl/src/crypto/ui/ui_lib.c b/lib/libssl/src/crypto/ui/ui_lib.c
index ee76e5e64d2..5335b59c483 100644
--- a/lib/libssl/src/crypto/ui/ui_lib.c
+++ b/lib/libssl/src/crypto/ui/ui_lib.c
@@ -827,31 +827,26 @@ UI_set_result(UI *ui, UI_STRING *uis, const char *result)
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];
-
- (void) snprintf(number1, sizeof(number1), "%d",
- uis->_.string_data.result_minsize);
- (void) snprintf(number2, sizeof(number2), "%d",
- uis->_.string_data.result_maxsize);
-
- if (l < uis->_.string_data.result_minsize) {
- ui->flags |= UI_FLAG_REDOABLE;
- UIerr(UI_F_UI_SET_RESULT, UI_R_RESULT_TOO_SMALL);
- ERR_add_error_data(5, "You must type in ",
- number1, " to ", number2, " characters");
- return -1;
- }
- if (l > uis->_.string_data.result_maxsize) {
- ui->flags |= UI_FLAG_REDOABLE;
- UIerr(UI_F_UI_SET_RESULT, UI_R_RESULT_TOO_LARGE);
- ERR_add_error_data(5, "You must type in ",
- number1, " to ", number2, " characters");
- return -1;
- }
+ if (l < uis->_.string_data.result_minsize) {
+ ui->flags |= UI_FLAG_REDOABLE;
+ UIerr(UI_F_UI_SET_RESULT,
+ UI_R_RESULT_TOO_SMALL);
+ ERR_asprintf_error_data
+ ("You must type in %d to %d characters",
+ uis->_.string_data.result_minsize,
+ uis->_.string_data.result_maxsize);
+ return -1;
+ }
+ if (l > uis->_.string_data.result_maxsize) {
+ ui->flags |= UI_FLAG_REDOABLE;
+ UIerr(UI_F_UI_SET_RESULT,
+ UI_R_RESULT_TOO_LARGE);
+ ERR_asprintf_error_data
+ ("You must type in %d to %d characters",
+ uis->_.string_data.result_minsize,
+ uis->_.string_data.result_maxsize);
+ return -1;
}
-
if (!uis->result_buf) {
UIerr(UI_F_UI_SET_RESULT, UI_R_NO_RESULT_BUFFER);
return -1;