forked from wolfSSL/wolfssl
remove error queue from JNI build and put a default max on error queue size
This commit is contained in:
@ -6447,6 +6447,9 @@ AS_IF([test "x$ENABLED_ED25519" = "xyes" && test "x$ENABLED_32BIT" = "xno"],
|
||||
AS_IF([test "x$ENABLED_ED25519_SMALL" = "xyes"],
|
||||
[AM_CFLAGS="$AM_CFLAGS -DED25519_SMALL"])
|
||||
|
||||
# Turn off error queue with JNI Java use
|
||||
AS_IF([test "x$ENABLED_JNI" = "xyes"],
|
||||
[AM_CFLAGS="$AM_CFLAGS -DNO_ERROR_QUEUE"])
|
||||
|
||||
if test "$ENABLED_ED25519_STREAM" != "no"
|
||||
then
|
||||
|
@ -71,6 +71,17 @@ THREAD_LS_T
|
||||
#endif
|
||||
struct wc_error_queue* wc_last_node;
|
||||
/* pointer to last node in queue to make insertion O(1) */
|
||||
|
||||
#ifndef ERROR_QUEUE_MAX
|
||||
/* this breaks from compat of unlimited error queue size */
|
||||
#define ERROR_QUEUE_MAX 100
|
||||
#endif
|
||||
static
|
||||
#ifdef ERROR_QUEUE_PER_THREAD
|
||||
THREAD_LS_T
|
||||
#endif
|
||||
int wc_error_queue_count = 0;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_FUNC_TIME
|
||||
@ -474,17 +485,25 @@ void WOLFSSL_ERROR(int error)
|
||||
XSNPRINTF(buffer, sizeof(buffer),
|
||||
"wolfSSL error occurred, error = %d line:%d file:%s",
|
||||
error, line, file);
|
||||
if (wc_AddErrorNode(error, line, buffer, (char*)file) != 0) {
|
||||
WOLFSSL_MSG("Error creating logging node");
|
||||
/* with void function there is no return here, continue on
|
||||
* to unlock mutex and log what buffer was created. */
|
||||
|
||||
if (wc_error_queue_count >= ERROR_QUEUE_MAX) {
|
||||
WOLFSSL_MSG("Error queue is full, at ERROR_QUEUE_MAX");
|
||||
}
|
||||
else {
|
||||
if (wc_AddErrorNode(error, line, buffer, (char*)file) != 0) {
|
||||
WOLFSSL_MSG("Error creating logging node");
|
||||
/* with void function there is no return here, continue on
|
||||
* to unlock mutex and log what buffer was created. */
|
||||
}
|
||||
else {
|
||||
wc_error_queue_count++;
|
||||
}
|
||||
}
|
||||
#if defined(OPENSSL_EXTRA) && !defined(WOLFCRYPT_ONLY)
|
||||
}
|
||||
else {
|
||||
XSNPRINTF(buffer, sizeof(buffer),
|
||||
"wolfSSL error occurred, error = %d", error);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -522,6 +541,7 @@ int wc_LoggingInit(void)
|
||||
WOLFSSL_MSG("Bad Init Mutex");
|
||||
return BAD_MUTEX_E;
|
||||
}
|
||||
wc_error_queue_count = 0;
|
||||
wc_errors = NULL;
|
||||
wc_current_node = NULL;
|
||||
wc_last_node = NULL;
|
||||
@ -768,6 +788,7 @@ void wc_RemoveErrorNode(int idx)
|
||||
if (wc_current_node == current)
|
||||
wc_current_node = current->next;
|
||||
XFREE(current, current->heap, DYNAMIC_TYPE_LOG);
|
||||
wc_error_queue_count--;
|
||||
}
|
||||
|
||||
wc_UnLockMutex(&debug_mutex);
|
||||
@ -799,6 +820,7 @@ void wc_ClearErrorNodes(void)
|
||||
}
|
||||
}
|
||||
|
||||
wc_error_queue_count = 0;
|
||||
wc_errors = NULL;
|
||||
wc_last_node = NULL;
|
||||
wc_current_node = NULL;
|
||||
@ -840,6 +862,7 @@ int wc_ERR_remove_state(void)
|
||||
current = next;
|
||||
}
|
||||
|
||||
wc_error_queue_count = 0;
|
||||
wc_errors = NULL;
|
||||
wc_last_node = NULL;
|
||||
|
||||
@ -889,6 +912,7 @@ void wc_ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
|
||||
}
|
||||
|
||||
/* set global pointers to match having been freed */
|
||||
wc_error_queue_count = 0;
|
||||
wc_errors = NULL;
|
||||
wc_last_node = NULL;
|
||||
|
||||
|
Reference in New Issue
Block a user