From b40ccdbcc5e7b475fa264ec7f4c9e9a8aab93285 Mon Sep 17 00:00:00 2001 From: Krzysztof Jackiewicz Date: Fri, 27 May 2016 08:55:01 +0200 Subject: [PATCH] Update openssl error handling. ERROR_DUMP always clears the error queue. ERROR_CLEAR clears the queue silently. One of them has to be called after an openssl error. ERROR_DUMP should be called for errors that we do not recognize. ERROR_CLEAR for other errors. Change-Id: I90844271378a87f4897f66c9664edf60bcb1e218 --- src/debug.c | 4 +++- src/internal.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/debug.c b/src/debug.c index 2bdaa74..4192585 100644 --- a/src/debug.c +++ b/src/debug.c @@ -42,8 +42,10 @@ API void yaca_debug_set_error_cb(yaca_error_cb fn) void error_dump(const char *file, int line, const char *function, int code) { - if (error_cb == NULL) + if (error_cb == NULL) { + ERR_clear_error(); return; + } static const size_t BUF_SIZE = 512; static const char ELLIPSIS[] = "...\n"; diff --git a/src/internal.h b/src/internal.h index 0aa764a..0e87776 100644 --- a/src/internal.h +++ b/src/internal.h @@ -26,6 +26,7 @@ #include #include +#include #include @@ -102,5 +103,6 @@ struct yaca_key_evp_s *key_get_evp(const yaca_key_h key); void error_dump(const char *file, int line, const char *function, int code); #define ERROR_DUMP(code) error_dump(__FILE__, __LINE__, __func__, (code)) +#define ERROR_CLEAR() ERR_clear_error() #endif /* YACA_INTERNAL_H */ -- 2.7.4