summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ui/ui_lib.c
diff options
context:
space:
mode:
authorbeck <>2014-04-26 18:56:38 +0000
committerbeck <>2014-04-26 18:56:38 +0000
commit47bb6e76785f0b1c4d19d8d0a02f3eb3813f96e2 (patch)
treedff54039de6c4454b05953e2ce78edfc5693e6b5 /src/lib/libcrypto/ui/ui_lib.c
parent8f710803a9e330d7e3f2e62116ae5b3fc02bd6cf (diff)
downloadopenbsd-47bb6e76785f0b1c4d19d8d0a02f3eb3813f96e2.tar.gz
openbsd-47bb6e76785f0b1c4d19d8d0a02f3eb3813f96e2.tar.bz2
openbsd-47bb6e76785f0b1c4d19d8d0a02f3eb3813f96e2.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 'src/lib/libcrypto/ui/ui_lib.c')
-rw-r--r--src/lib/libcrypto/ui/ui_lib.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c
index ee76e5e64d..5335b59c48 100644
--- a/src/lib/libcrypto/ui/ui_lib.c
+++ b/src/lib/libcrypto/ui/ui_lib.c
@@ -827,31 +827,26 @@ UI_set_result(UI *ui, UI_STRING *uis, const char *result)
827 switch (uis->type) { 827 switch (uis->type) {
828 case UIT_PROMPT: 828 case UIT_PROMPT:
829 case UIT_VERIFY: 829 case UIT_VERIFY:
830 { 830 if (l < uis->_.string_data.result_minsize) {
831 char number1[DECIMAL_SIZE(uis->_.string_data.result_minsize) + 1]; 831 ui->flags |= UI_FLAG_REDOABLE;
832 char number2[DECIMAL_SIZE(uis->_.string_data.result_maxsize) + 1]; 832 UIerr(UI_F_UI_SET_RESULT,
833 833 UI_R_RESULT_TOO_SMALL);
834 (void) snprintf(number1, sizeof(number1), "%d", 834 ERR_asprintf_error_data
835 uis->_.string_data.result_minsize); 835 ("You must type in %d to %d characters",
836 (void) snprintf(number2, sizeof(number2), "%d", 836 uis->_.string_data.result_minsize,
837 uis->_.string_data.result_maxsize); 837 uis->_.string_data.result_maxsize);
838 838 return -1;
839 if (l < uis->_.string_data.result_minsize) { 839 }
840 ui->flags |= UI_FLAG_REDOABLE; 840 if (l > uis->_.string_data.result_maxsize) {
841 UIerr(UI_F_UI_SET_RESULT, UI_R_RESULT_TOO_SMALL); 841 ui->flags |= UI_FLAG_REDOABLE;
842 ERR_add_error_data(5, "You must type in ", 842 UIerr(UI_F_UI_SET_RESULT,
843 number1, " to ", number2, " characters"); 843 UI_R_RESULT_TOO_LARGE);
844 return -1; 844 ERR_asprintf_error_data
845 } 845 ("You must type in %d to %d characters",
846 if (l > uis->_.string_data.result_maxsize) { 846 uis->_.string_data.result_minsize,
847 ui->flags |= UI_FLAG_REDOABLE; 847 uis->_.string_data.result_maxsize);
848 UIerr(UI_F_UI_SET_RESULT, UI_R_RESULT_TOO_LARGE); 848 return -1;
849 ERR_add_error_data(5, "You must type in ",
850 number1, " to ", number2, " characters");
851 return -1;
852 }
853 } 849 }
854
855 if (!uis->result_buf) { 850 if (!uis->result_buf) {
856 UIerr(UI_F_UI_SET_RESULT, UI_R_NO_RESULT_BUFFER); 851 UIerr(UI_F_UI_SET_RESULT, UI_R_NO_RESULT_BUFFER);
857 return -1; 852 return -1;