Openssl defines a bit flag ERR_R_FATAL = 64 which may be used with common error
reasons (ERR_R_...). However, it's possible that library specific error reasons
(>99) have the bit set as well. ERR_FATAL_ERROR macro doesn't check it. Check
added.
Change-Id: I92b8b1011d0d22b84ec7e43f53bc60431cfe17fd
// TODO any better idea than to use __thread?
static __thread yaca_error_cb error_cb = NULL;
static bool error_strings_loaded = false;
+static const int GENERIC_REASON_MAX = 99;
API void yaca_debug_set_error_cb(yaca_error_cb fn)
{
}
/* fatal errors */
- if (ret == YACA_ERROR_NONE && ERR_FATAL_ERROR(err) > 0) {
- switch (ERR_GET_REASON(err)) {
+ int reason = ERR_GET_REASON(err);
+ if (ret == YACA_ERROR_NONE && reason <= GENERIC_REASON_MAX && ERR_FATAL_ERROR(err) > 0) {
+ switch (reason) {
case ERR_R_MALLOC_FAILURE:
ret = YACA_ERROR_OUT_OF_MEMORY;
break;