From 96b347c200b2401d02f576b47da8a49cc6286b4b Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 31 Aug 2017 14:49:48 -0400 Subject: Add a mechanism to print openssl errors Signed-off-by: Peter Jones --- lib/console.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'lib/console.c') diff --git a/lib/console.c b/lib/console.c index 31ac110d..cd8d1de2 100644 --- a/lib/console.c +++ b/lib/console.c @@ -6,10 +6,14 @@ */ #include #include - +#include +#include #include #include #include +#include +#include +#include static EFI_GUID SHIM_LOCK_GUID = { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23} }; @@ -383,7 +387,6 @@ err_string ( return L""; } - void console_error(CHAR16 *err, EFI_STATUS status) @@ -396,7 +399,8 @@ console_error(CHAR16 *err, EFI_STATUS status) }; CHAR16 str[512]; - SPrint(str, sizeof(str), L"%s: (%d) %s", err, status, err_string(status)); + SPrint(str, sizeof(str), L"%s: (0x%x) %s", err, status, err_string(status)); + err_arr[2] = str; @@ -460,6 +464,26 @@ VOID setup_console (int text) uefi_call_wrapper(concon->SetMode, 2, concon, new_mode); } +static int +print_errors_cb(const char *str, size_t len, void *u) +{ + Print(L"%a", str); + + return len; +} + +EFI_STATUS +print_crypto_errors(EFI_STATUS rc, char *file, const char *func, int line) +{ + if (!(verbose && EFI_ERROR(rc))) + return rc; + + Print(L"SSL Error: %a:%d %a(): %r\n", file, line, func, rc); + ERR_print_errors_cb(print_errors_cb, NULL); + + return rc; +} + VOID msleep(unsigned long msecs) { -- cgit v1.2.3