mirror of https://github.com/wolfSSL/wolfssl.git
Merge pull request #4448 from JacobBarthelmeh/Compatibility-Layer
remove error queue from JNI build and set a default upper bound on itpull/4458/head
commit
dd6e4093b3
12
configure.ac
12
configure.ac
|
@ -2436,12 +2436,6 @@ AC_ARG_ENABLE([errorqueue],
|
|||
[ ENABLED_ERROR_QUEUE=yes ]
|
||||
)
|
||||
|
||||
if test "$ENABLED_ERROR_QUEUE" = "no"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DNO_ERROR_QUEUE"
|
||||
fi
|
||||
|
||||
|
||||
# OLD TLS
|
||||
AC_ARG_ENABLE([oldtls],
|
||||
[AS_HELP_STRING([--enable-oldtls],[Enable old TLS versions < 1.2 (default: enabled)])],
|
||||
|
@ -6462,13 +6456,17 @@ 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"])
|
||||
|
||||
|
||||
if test "$ENABLED_ED25519_STREAM" != "no"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ED25519_STREAMING_VERIFY"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_ED25519_STREAMING_VERIFY"
|
||||
fi
|
||||
|
||||
if test "$ENABLED_ERROR_QUEUE" = "no" || test "$ENABLED_JNI" = "yes"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DNO_ERROR_QUEUE"
|
||||
fi
|
||||
|
||||
AS_IF([test "x$ENABLED_OPENSSLALL" = "xyes"],
|
||||
[AM_CFLAGS="-DOPENSSL_ALL -DWOLFSSL_EITHER_SIDE -DWC_RSA_NO_PADDING -DWC_RSA_PSS -DWOLFSSL_PSS_LONG_SALT $AM_CFLAGS"])
|
||||
|
||||
|
|
13
tests/api.c
13
tests/api.c
|
@ -36130,6 +36130,19 @@ static THREAD_RETURN WOLFSSL_THREAD test_logging(void* args)
|
|||
}
|
||||
AssertIntEQ(errorCount, ERROR_COUNT);
|
||||
|
||||
/* test max queue behavior, trying to add an arbitrary 3 errors over */
|
||||
errorCount = 0;
|
||||
for (i = 0; i < ERROR_QUEUE_MAX + 3; i++)
|
||||
ERR_put_error(ERR_LIB_PEM, SYS_F_ACCEPT, -990 - i, __FILE__, __LINE__);
|
||||
|
||||
while ((err = ERR_get_error_line(&file, &line))) {
|
||||
AssertIntEQ(err, 990 + errorCount);
|
||||
errorCount++;
|
||||
}
|
||||
|
||||
/* test that the 3 errors over the max were dropped */
|
||||
AssertIntEQ(errorCount, ERROR_QUEUE_MAX);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -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,6 +485,7 @@ 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
|
||||
|
@ -484,7 +496,6 @@ void WOLFSSL_ERROR(int error)
|
|||
else {
|
||||
XSNPRINTF(buffer, sizeof(buffer),
|
||||
"wolfSSL error occurred, error = %d", error);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -522,6 +533,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;
|
||||
|
@ -667,6 +679,12 @@ int wc_AddErrorNode(int error, int line, char* buf, char* file)
|
|||
WOLFSSL_MSG("Error queue turned off, can not add nodes");
|
||||
#else
|
||||
struct wc_error_queue* err;
|
||||
|
||||
if (wc_error_queue_count >= ERROR_QUEUE_MAX) {
|
||||
WOLFSSL_MSG("Error queue is full, at ERROR_QUEUE_MAX");
|
||||
return MEMORY_E;
|
||||
}
|
||||
|
||||
err = (struct wc_error_queue*)XMALLOC(
|
||||
sizeof(struct wc_error_queue), wc_error_heap, DYNAMIC_TYPE_LOG);
|
||||
if (err == NULL) {
|
||||
|
@ -731,6 +749,7 @@ int wc_AddErrorNode(int error, int line, char* buf, char* file)
|
|||
wc_current_node = err;
|
||||
}
|
||||
}
|
||||
wc_error_queue_count++;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
|
@ -768,6 +787,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 +819,7 @@ void wc_ClearErrorNodes(void)
|
|||
}
|
||||
}
|
||||
|
||||
wc_error_queue_count = 0;
|
||||
wc_errors = NULL;
|
||||
wc_last_node = NULL;
|
||||
wc_current_node = NULL;
|
||||
|
@ -840,6 +861,7 @@ int wc_ERR_remove_state(void)
|
|||
current = next;
|
||||
}
|
||||
|
||||
wc_error_queue_count = 0;
|
||||
wc_errors = NULL;
|
||||
wc_last_node = NULL;
|
||||
|
||||
|
@ -889,6 +911,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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue