From 189a4d74c07aeb58f990fd27133a2caf0e7df176 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Thu, 27 Apr 2017 11:03:07 -0600 Subject: [PATCH] implement get error line data function --- src/ssl.c | 28 +++++++++++++++++++--------- tests/api.c | 5 +++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index 3df58aa42..2bfa76695 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -14674,20 +14674,30 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md) } - #ifndef NO_WOLFSSL_STUB + /* Similar to wolfSSL_ERR_get_error_line but takes in a flags argument for + * more flexability. + * + * file output pointer to file where error happened + * line output to line number of error + * data output data. Is a string if ERR_TXT_STRING flag is used + * flags bit flag to adjust data output + * + * Returns the error value + */ unsigned long wolfSSL_ERR_get_error_line_data(const char** file, int* line, const char** data, int *flags) { - /* Not implemented */ - (void)file; - (void)line; - (void)data; - (void)flags; - WOLFSSL_STUB("ERR_get_error_line_data"); + WOLFSSL_STUB("wolfSSL_ERR_get_error_line_data"); - return 0; + if (flags != NULL) { + if ((*flags & ERR_TXT_STRING) == ERR_TXT_STRING) { + return wc_PullErrorNode(file, data, line); + } + } + + return wc_PullErrorNode(file, NULL, line); } - #endif + WOLFSSL_API pem_password_cb* wolfSSL_CTX_get_default_passwd_cb( WOLFSSL_CTX *ctx) diff --git a/tests/api.c b/tests/api.c index 918bf5541..690778740 100644 --- a/tests/api.c +++ b/tests/api.c @@ -14236,7 +14236,9 @@ static void test_wolfSSL_ERR_peek_last_error_line(void) callback_functions client_cb; callback_functions server_cb; int line = 0; + int flag = ERR_TXT_STRING; const char* file = NULL; + const char* data = NULL; printf(testingFmt, "wolfSSL_ERR_peek_last_error_line()"); @@ -14269,6 +14271,9 @@ static void test_wolfSSL_ERR_peek_last_error_line(void) FreeTcpReady(&ready); + AssertIntGT(ERR_get_error_line_data(NULL, NULL, &data, &flag), 0); + AssertNotNull(data); + /* check clearing error state */ ERR_remove_state(0); AssertIntEQ((int)ERR_peek_last_error_line(NULL, NULL), 0);