forked from wolfSSL/wolfssl
tying in lean staticmemory build with --enable-staticmemory=small
This commit is contained in:
13
configure.ac
13
configure.ac
@@ -8070,6 +8070,19 @@ AC_ARG_ENABLE([staticmemory],
|
|||||||
[ ENABLED_STATICMEMORY=no ]
|
[ ENABLED_STATICMEMORY=no ]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for v in `echo $ENABLED_STATICMEMORY | tr "," " "`
|
||||||
|
do
|
||||||
|
case $v in
|
||||||
|
small)
|
||||||
|
ENABLED_STATICMEMORY=yes
|
||||||
|
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_LEAN_STATIC_MEMORY"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR([Invalid choice for staticmemory.])
|
||||||
|
break;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if test "x$ENABLED_STATICMEMORY" = "xyes"
|
if test "x$ENABLED_STATICMEMORY" = "xyes"
|
||||||
then
|
then
|
||||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_STATIC_MEMORY"
|
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_STATIC_MEMORY"
|
||||||
|
@@ -2096,10 +2096,12 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
byte memory[80000];
|
byte memory[80000];
|
||||||
#endif
|
#endif
|
||||||
byte memoryIO[34500]; /* max for IO buffer (TLS packet can be 16k) */
|
byte memoryIO[34500]; /* max for IO buffer (TLS packet can be 16k) */
|
||||||
|
#if !defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
WOLFSSL_MEM_CONN_STATS ssl_stats;
|
WOLFSSL_MEM_CONN_STATS ssl_stats;
|
||||||
#ifdef DEBUG_WOLFSSL
|
#if defined(DEBUG_WOLFSSL)
|
||||||
WOLFSSL_MEM_STATS mem_stats;
|
WOLFSSL_MEM_STATS mem_stats;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
WOLFSSL_HEAP_HINT *heap = NULL;
|
WOLFSSL_HEAP_HINT *heap = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -3026,7 +3028,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_STATIC_MEMORY
|
#ifdef WOLFSSL_STATIC_MEMORY
|
||||||
#ifdef DEBUG_WOLFSSL
|
#if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
/* print off helper buffer sizes for use with static memory
|
/* print off helper buffer sizes for use with static memory
|
||||||
* printing to stderr in case of debug mode turned on */
|
* printing to stderr in case of debug mode turned on */
|
||||||
LOG_ERROR("static memory management size = %d\n",
|
LOG_ERROR("static memory management size = %d\n",
|
||||||
@@ -3584,7 +3586,8 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WOLFSSL_STATIC_MEMORY) && defined(DEBUG_WOLFSSL)
|
#if defined(WOLFSSL_STATIC_MEMORY) && defined(DEBUG_WOLFSSL) && \
|
||||||
|
!defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
LOG_ERROR("Before creating SSL\n");
|
LOG_ERROR("Before creating SSL\n");
|
||||||
if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) != 1)
|
if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) != 1)
|
||||||
err_sys("ctx not using static memory");
|
err_sys("ctx not using static memory");
|
||||||
@@ -3682,7 +3685,8 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WOLFSSL_STATIC_MEMORY) && defined(DEBUG_WOLFSSL)
|
#if defined(WOLFSSL_STATIC_MEMORY) && defined(DEBUG_WOLFSSL) && \
|
||||||
|
!defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
LOG_ERROR("After creating SSL\n");
|
LOG_ERROR("After creating SSL\n");
|
||||||
if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) != 1)
|
if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) != 1)
|
||||||
err_sys("ctx not using static memory");
|
err_sys("ctx not using static memory");
|
||||||
@@ -4390,7 +4394,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* display collected statistics */
|
/* display collected statistics */
|
||||||
#ifdef WOLFSSL_STATIC_MEMORY
|
#if defined(WOLFSSL_STATIC_MEMORY) && !defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
if (wolfSSL_is_static_memory(ssl, &ssl_stats) != 1)
|
if (wolfSSL_is_static_memory(ssl, &ssl_stats) != 1)
|
||||||
err_sys("static memory was not used with ssl");
|
err_sys("static memory was not used with ssl");
|
||||||
|
|
||||||
@@ -4617,7 +4621,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
wolfSSL_shutdown(sslResume); /* bidirectional shutdown */
|
wolfSSL_shutdown(sslResume); /* bidirectional shutdown */
|
||||||
|
|
||||||
/* display collected statistics */
|
/* display collected statistics */
|
||||||
#ifdef WOLFSSL_STATIC_MEMORY
|
#if defined(WOLFSSL_STATIC_MEMORY) && !defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
if (wolfSSL_is_static_memory(sslResume, &ssl_stats) != 1)
|
if (wolfSSL_is_static_memory(sslResume, &ssl_stats) != 1)
|
||||||
err_sys("static memory was not used with ssl");
|
err_sys("static memory was not used with ssl");
|
||||||
|
|
||||||
|
@@ -1601,10 +1601,12 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
|||||||
byte memory[80000];
|
byte memory[80000];
|
||||||
#endif
|
#endif
|
||||||
byte memoryIO[34500]; /* max for IO buffer (TLS packet can be 16k) */
|
byte memoryIO[34500]; /* max for IO buffer (TLS packet can be 16k) */
|
||||||
|
#if !defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
WOLFSSL_MEM_CONN_STATS ssl_stats;
|
WOLFSSL_MEM_CONN_STATS ssl_stats;
|
||||||
#ifdef DEBUG_WOLFSSL
|
#if defined(DEBUG_WOLFSSL)
|
||||||
WOLFSSL_MEM_STATS mem_stats;
|
WOLFSSL_MEM_STATS mem_stats;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)
|
#if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)
|
||||||
int onlyKeyShare = 0;
|
int onlyKeyShare = 0;
|
||||||
@@ -2503,7 +2505,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
|||||||
err_sys_ex(runWithErrors, "unable to get method");
|
err_sys_ex(runWithErrors, "unable to get method");
|
||||||
|
|
||||||
#ifdef WOLFSSL_STATIC_MEMORY
|
#ifdef WOLFSSL_STATIC_MEMORY
|
||||||
#ifdef DEBUG_WOLFSSL
|
#if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
/* print off helper buffer sizes for use with static memory
|
/* print off helper buffer sizes for use with static memory
|
||||||
* printing to stderr in case of debug mode turned on */
|
* printing to stderr in case of debug mode turned on */
|
||||||
LOG_ERROR("static memory management size = %d\n",
|
LOG_ERROR("static memory management size = %d\n",
|
||||||
@@ -2964,7 +2966,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
|||||||
err_sys_ex(runWithErrors, "tcp accept failed");
|
err_sys_ex(runWithErrors, "tcp accept failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(WOLFSSL_STATIC_MEMORY) && defined(DEBUG_WOLFSSL)
|
#if defined(WOLFSSL_STATIC_MEMORY) && defined(DEBUG_WOLFSSL) && \
|
||||||
|
!defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
LOG_ERROR("Before creating SSL\n");
|
LOG_ERROR("Before creating SSL\n");
|
||||||
if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) != 1)
|
if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) != 1)
|
||||||
err_sys_ex(runWithErrors, "ctx not using static memory");
|
err_sys_ex(runWithErrors, "ctx not using static memory");
|
||||||
@@ -3053,7 +3056,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WOLFSSL_STATIC_MEMORY) && defined(DEBUG_WOLFSSL)
|
#if defined(WOLFSSL_STATIC_MEMORY) && defined(DEBUG_WOLFSSL) && \
|
||||||
|
!defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
LOG_ERROR("After creating SSL\n");
|
LOG_ERROR("After creating SSL\n");
|
||||||
if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) != 1)
|
if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) != 1)
|
||||||
err_sys_ex(runWithErrors, "ctx not using static memory");
|
err_sys_ex(runWithErrors, "ctx not using static memory");
|
||||||
@@ -3799,7 +3803,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* display collected statistics */
|
/* display collected statistics */
|
||||||
#ifdef WOLFSSL_STATIC_MEMORY
|
#if defined(WOLFSSL_STATIC_MEMORY) && !defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
if (wolfSSL_is_static_memory(ssl, &ssl_stats) != 1)
|
if (wolfSSL_is_static_memory(ssl, &ssl_stats) != 1)
|
||||||
err_sys_ex(runWithErrors, "static memory was not used with ssl");
|
err_sys_ex(runWithErrors, "static memory was not used with ssl");
|
||||||
|
|
||||||
|
@@ -7241,6 +7241,8 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup)
|
|||||||
ssl_hint = ((WOLFSSL_HEAP_HINT*)(ssl->heap));
|
ssl_hint = ((WOLFSSL_HEAP_HINT*)(ssl->heap));
|
||||||
ctx_hint = ((WOLFSSL_HEAP_HINT*)(ctx->heap));
|
ctx_hint = ((WOLFSSL_HEAP_HINT*)(ctx->heap));
|
||||||
|
|
||||||
|
ssl_hint->memory = ctx_hint->memory;
|
||||||
|
#ifndef WOLFSSL_LEAN_STATIC_MEMORY
|
||||||
/* lock and check IO count / handshake count */
|
/* lock and check IO count / handshake count */
|
||||||
if (wc_LockMutex(&(ctx_hint->memory->memory_mutex)) != 0) {
|
if (wc_LockMutex(&(ctx_hint->memory->memory_mutex)) != 0) {
|
||||||
WOLFSSL_MSG("Bad memory_mutex lock");
|
WOLFSSL_MSG("Bad memory_mutex lock");
|
||||||
@@ -7268,7 +7270,6 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup)
|
|||||||
}
|
}
|
||||||
ctx_hint->memory->curIO++;
|
ctx_hint->memory->curIO++;
|
||||||
ctx_hint->memory->curHa++;
|
ctx_hint->memory->curHa++;
|
||||||
ssl_hint->memory = ctx_hint->memory;
|
|
||||||
ssl_hint->haFlag = 1;
|
ssl_hint->haFlag = 1;
|
||||||
wc_UnLockMutex(&(ctx_hint->memory->memory_mutex));
|
wc_UnLockMutex(&(ctx_hint->memory->memory_mutex));
|
||||||
|
|
||||||
@@ -7304,6 +7305,7 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup)
|
|||||||
}
|
}
|
||||||
wc_UnLockMutex(&(ctx_hint->memory->memory_mutex));
|
wc_UnLockMutex(&(ctx_hint->memory->memory_mutex));
|
||||||
}
|
}
|
||||||
|
#endif /* !WOLFSSL_LEAN_STATIC_MEMORY */
|
||||||
#ifdef WOLFSSL_HEAP_TEST
|
#ifdef WOLFSSL_HEAP_TEST
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -8382,14 +8384,17 @@ void SSL_ResourceFree(WOLFSSL* ssl)
|
|||||||
/* avoid dereferencing a test value */
|
/* avoid dereferencing a test value */
|
||||||
if (ssl->heap != (void*)WOLFSSL_HEAP_TEST) {
|
if (ssl->heap != (void*)WOLFSSL_HEAP_TEST) {
|
||||||
#endif
|
#endif
|
||||||
|
void* heap = ssl->ctx ? ssl->ctx->heap : ssl->heap;
|
||||||
|
#ifndef WOLFSSL_LEAN_STATIC_MEMORY
|
||||||
WOLFSSL_HEAP_HINT* ssl_hint = (WOLFSSL_HEAP_HINT*)ssl->heap;
|
WOLFSSL_HEAP_HINT* ssl_hint = (WOLFSSL_HEAP_HINT*)ssl->heap;
|
||||||
WOLFSSL_HEAP* ctx_heap;
|
WOLFSSL_HEAP* ctx_heap;
|
||||||
void* heap = ssl->ctx ? ssl->ctx->heap : ssl->heap;
|
|
||||||
|
|
||||||
ctx_heap = ssl_hint->memory;
|
ctx_heap = ssl_hint->memory;
|
||||||
|
#ifndef SINGLE_THREADED
|
||||||
if (wc_LockMutex(&(ctx_heap->memory_mutex)) != 0) {
|
if (wc_LockMutex(&(ctx_heap->memory_mutex)) != 0) {
|
||||||
WOLFSSL_MSG("Bad memory_mutex lock");
|
WOLFSSL_MSG("Bad memory_mutex lock");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
ctx_heap->curIO--;
|
ctx_heap->curIO--;
|
||||||
if (FreeFixedIO(ctx_heap, &(ssl_hint->outBuf)) != 1) {
|
if (FreeFixedIO(ctx_heap, &(ssl_hint->outBuf)) != 1) {
|
||||||
WOLFSSL_MSG("Error freeing fixed output buffer");
|
WOLFSSL_MSG("Error freeing fixed output buffer");
|
||||||
@@ -8397,15 +8402,20 @@ void SSL_ResourceFree(WOLFSSL* ssl)
|
|||||||
if (FreeFixedIO(ctx_heap, &(ssl_hint->inBuf)) != 1) {
|
if (FreeFixedIO(ctx_heap, &(ssl_hint->inBuf)) != 1) {
|
||||||
WOLFSSL_MSG("Error freeing fixed output buffer");
|
WOLFSSL_MSG("Error freeing fixed output buffer");
|
||||||
}
|
}
|
||||||
if (ssl_hint->haFlag && ctx_heap->curHa > 0) { /* check if handshake count has been decreased*/
|
|
||||||
|
/* check if handshake count has been decreased*/
|
||||||
|
if (ssl_hint->haFlag && ctx_heap->curHa > 0) {
|
||||||
ctx_heap->curHa--;
|
ctx_heap->curHa--;
|
||||||
}
|
}
|
||||||
|
#ifndef SINGLE_THREADED
|
||||||
wc_UnLockMutex(&(ctx_heap->memory_mutex));
|
wc_UnLockMutex(&(ctx_heap->memory_mutex));
|
||||||
|
#endif
|
||||||
|
|
||||||
/* check if tracking stats */
|
/* check if tracking stats */
|
||||||
if (ctx_heap->flag & WOLFMEM_TRACK_STATS) {
|
if (ctx_heap->flag & WOLFMEM_TRACK_STATS) {
|
||||||
XFREE(ssl_hint->stats, heap, DYNAMIC_TYPE_SSL);
|
XFREE(ssl_hint->stats, heap, DYNAMIC_TYPE_SSL);
|
||||||
}
|
}
|
||||||
|
#endif /* !WOLFSSL_LEAN_STATIC_MEMORY */
|
||||||
XFREE(ssl->heap, heap, DYNAMIC_TYPE_SSL);
|
XFREE(ssl->heap, heap, DYNAMIC_TYPE_SSL);
|
||||||
#ifdef WOLFSSL_HEAP_TEST
|
#ifdef WOLFSSL_HEAP_TEST
|
||||||
}
|
}
|
||||||
@@ -8673,14 +8683,20 @@ void FreeHandshakeResources(WOLFSSL* ssl)
|
|||||||
WOLFSSL_HEAP* ctx_heap;
|
WOLFSSL_HEAP* ctx_heap;
|
||||||
|
|
||||||
ctx_heap = ssl_hint->memory;
|
ctx_heap = ssl_hint->memory;
|
||||||
|
#ifndef SINGLE_THREADED
|
||||||
if (wc_LockMutex(&(ctx_heap->memory_mutex)) != 0) {
|
if (wc_LockMutex(&(ctx_heap->memory_mutex)) != 0) {
|
||||||
WOLFSSL_MSG("Bad memory_mutex lock");
|
WOLFSSL_MSG("Bad memory_mutex lock");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifndef WOLFSSL_LEAN_STATIC_MEMORY
|
||||||
if (ctx_heap->curHa > 0) {
|
if (ctx_heap->curHa > 0) {
|
||||||
ctx_heap->curHa--;
|
ctx_heap->curHa--;
|
||||||
}
|
}
|
||||||
ssl_hint->haFlag = 0; /* set to zero since handshake has been dec */
|
ssl_hint->haFlag = 0; /* set to zero since handshake has been dec */
|
||||||
|
#endif
|
||||||
|
#ifndef SINGLE_THREADED
|
||||||
wc_UnLockMutex(&(ctx_heap->memory_mutex));
|
wc_UnLockMutex(&(ctx_heap->memory_mutex));
|
||||||
|
#endif
|
||||||
#ifdef WOLFSSL_HEAP_TEST
|
#ifdef WOLFSSL_HEAP_TEST
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -2573,6 +2573,7 @@ int wolfSSL_is_static_memory(WOLFSSL* ssl, WOLFSSL_MEM_CONN_STATS* mem_stats)
|
|||||||
}
|
}
|
||||||
WOLFSSL_ENTER("wolfSSL_is_static_memory");
|
WOLFSSL_ENTER("wolfSSL_is_static_memory");
|
||||||
|
|
||||||
|
#ifndef WOLFSSL_LEAN_STATIC_MEMORY
|
||||||
/* fill out statistics if wanted and WOLFMEM_TRACK_STATS flag */
|
/* fill out statistics if wanted and WOLFMEM_TRACK_STATS flag */
|
||||||
if (mem_stats != NULL && ssl->heap != NULL) {
|
if (mem_stats != NULL && ssl->heap != NULL) {
|
||||||
WOLFSSL_HEAP_HINT* hint = ((WOLFSSL_HEAP_HINT*)(ssl->heap));
|
WOLFSSL_HEAP_HINT* hint = ((WOLFSSL_HEAP_HINT*)(ssl->heap));
|
||||||
@@ -2581,7 +2582,9 @@ int wolfSSL_is_static_memory(WOLFSSL* ssl, WOLFSSL_MEM_CONN_STATS* mem_stats)
|
|||||||
XMEMCPY(mem_stats, hint->stats, sizeof(WOLFSSL_MEM_CONN_STATS));
|
XMEMCPY(mem_stats, hint->stats, sizeof(WOLFSSL_MEM_CONN_STATS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
(void)mem_stats;
|
||||||
return (ssl->heap) ? 1 : 0;
|
return (ssl->heap) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2593,6 +2596,7 @@ int wolfSSL_CTX_is_static_memory(WOLFSSL_CTX* ctx, WOLFSSL_MEM_STATS* mem_stats)
|
|||||||
}
|
}
|
||||||
WOLFSSL_ENTER("wolfSSL_CTX_is_static_memory");
|
WOLFSSL_ENTER("wolfSSL_CTX_is_static_memory");
|
||||||
|
|
||||||
|
#ifndef WOLFSSL_LEAN_STATIC_MEMORY
|
||||||
/* fill out statistics if wanted */
|
/* fill out statistics if wanted */
|
||||||
if (mem_stats != NULL && ctx->heap != NULL) {
|
if (mem_stats != NULL && ctx->heap != NULL) {
|
||||||
WOLFSSL_HEAP* heap = ((WOLFSSL_HEAP_HINT*)(ctx->heap))->memory;
|
WOLFSSL_HEAP* heap = ((WOLFSSL_HEAP_HINT*)(ctx->heap))->memory;
|
||||||
@@ -2600,7 +2604,9 @@ int wolfSSL_CTX_is_static_memory(WOLFSSL_CTX* ctx, WOLFSSL_MEM_STATS* mem_stats)
|
|||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
(void)mem_stats;
|
||||||
return (ctx->heap) ? 1 : 0;
|
return (ctx->heap) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -66534,7 +66534,7 @@ static int test_wolfSSL_CTX_StaticMemory_SSL(WOLFSSL_CTX* ctx)
|
|||||||
ExpectNull((ssl3 = wolfSSL_new(ctx)));
|
ExpectNull((ssl3 = wolfSSL_new(ctx)));
|
||||||
|
|
||||||
if (wolfSSL_is_static_memory(ssl1, &ssl_stats) == 1) {
|
if (wolfSSL_is_static_memory(ssl1, &ssl_stats) == 1) {
|
||||||
#ifdef DEBUG_WOLFSSL
|
#if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
wolfSSL_PrintStatsConn(&ssl_stats);
|
wolfSSL_PrintStatsConn(&ssl_stats);
|
||||||
#endif
|
#endif
|
||||||
(void)ssl_stats;
|
(void)ssl_stats;
|
||||||
@@ -66542,7 +66542,7 @@ static int test_wolfSSL_CTX_StaticMemory_SSL(WOLFSSL_CTX* ctx)
|
|||||||
|
|
||||||
/* display collected statistics */
|
/* display collected statistics */
|
||||||
if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) == 1) {
|
if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) == 1) {
|
||||||
#ifdef DEBUG_WOLFSSL
|
#if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
wolfSSL_PrintStats(&mem_stats);
|
wolfSSL_PrintStats(&mem_stats);
|
||||||
#endif
|
#endif
|
||||||
(void)mem_stats;
|
(void)mem_stats;
|
||||||
|
@@ -610,7 +610,8 @@ static int wc_partition_static_memory(byte* buffer, word32 sz, int flag,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* divide into chunks of memory and add them to available list */
|
/* divide into chunks of memory and add them to available list */
|
||||||
while (ava >= (heap->sizeList[0] + padSz + memSz)) {
|
while (ava >= (word32)(heap->sizeList[0] + padSz + memSz)) {
|
||||||
|
#ifndef WOLFSSL_LEAN_STATIC_MEMORY
|
||||||
/* creating only IO buffers from memory passed in, max TLS is 16k */
|
/* creating only IO buffers from memory passed in, max TLS is 16k */
|
||||||
if (flag & WOLFMEM_IO_POOL || flag & WOLFMEM_IO_POOL_FIXED) {
|
if (flag & WOLFMEM_IO_POOL || flag & WOLFMEM_IO_POOL_FIXED) {
|
||||||
if ((ret = wc_create_memory_buckets(pt, ava,
|
if ((ret = wc_create_memory_buckets(pt, ava,
|
||||||
@@ -629,11 +630,13 @@ static int wc_partition_static_memory(byte* buffer, word32 sz, int flag,
|
|||||||
pt += ret;
|
pt += ret;
|
||||||
ava -= ret;
|
ava -= ret;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
/* start at largest and move to smaller buckets */
|
/* start at largest and move to smaller buckets */
|
||||||
for (i = (WOLFMEM_MAX_BUCKETS - 1); i >= 0; i--) {
|
for (i = (WOLFMEM_MAX_BUCKETS - 1); i >= 0; i--) {
|
||||||
if ((heap->sizeList[i] + padSz + memSz) <= ava) {
|
if ((word32)(heap->sizeList[i] + padSz + memSz) <= ava) {
|
||||||
if ((ret = wc_create_memory_buckets(pt, ava,
|
if ((ret = wc_create_memory_buckets(pt, ava,
|
||||||
heap->sizeList[i], heap->distList[i],
|
heap->sizeList[i], heap->distList[i],
|
||||||
&(heap->ava[i]))) < 0) {
|
&(heap->ava[i]))) < 0) {
|
||||||
@@ -650,6 +653,7 @@ static int wc_partition_static_memory(byte* buffer, word32 sz, int flag,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void)flag;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,6 +755,7 @@ int wc_LoadStaticMemory_ex(WOLFSSL_HEAP_HINT** pHint,
|
|||||||
#endif
|
#endif
|
||||||
*pHint = hint;
|
*pHint = hint;
|
||||||
|
|
||||||
|
(void)maxSz;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1054,7 +1059,7 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifndef WOLFSSL_LEANPSK
|
#ifndef WOLFSSL_LEAN_STATIC_MEMORY
|
||||||
/* check if using IO pool flag */
|
/* check if using IO pool flag */
|
||||||
if (mem->flag & WOLFMEM_IO_POOL &&
|
if (mem->flag & WOLFMEM_IO_POOL &&
|
||||||
(type == DYNAMIC_TYPE_OUT_BUFFER ||
|
(type == DYNAMIC_TYPE_OUT_BUFFER ||
|
||||||
@@ -1353,6 +1358,7 @@ void* wolfSSL_Realloc(void *ptr, size_t size, void* heap, int type)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef WOLFSSL_LEAN_STATIC_MEMORY
|
||||||
/* case of using fixed IO buffers or IO pool */
|
/* case of using fixed IO buffers or IO pool */
|
||||||
if (((mem->flag & WOLFMEM_IO_POOL)||(mem->flag & WOLFMEM_IO_POOL_FIXED))
|
if (((mem->flag & WOLFMEM_IO_POOL)||(mem->flag & WOLFMEM_IO_POOL_FIXED))
|
||||||
&& (type == DYNAMIC_TYPE_OUT_BUFFER ||
|
&& (type == DYNAMIC_TYPE_OUT_BUFFER ||
|
||||||
@@ -1365,7 +1371,9 @@ void* wolfSSL_Realloc(void *ptr, size_t size, void* heap, int type)
|
|||||||
}
|
}
|
||||||
res = pt->buffer;
|
res = pt->buffer;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
/* general memory */
|
/* general memory */
|
||||||
for (i = 0; i < WOLFMEM_MAX_BUCKETS; i++) {
|
for (i = 0; i < WOLFMEM_MAX_BUCKETS; i++) {
|
||||||
if ((word32)size <= mem->sizeList[i]) {
|
if ((word32)size <= mem->sizeList[i]) {
|
||||||
|
@@ -17406,6 +17406,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef WOLFSSL_LEAN_STATIC_MEMORY
|
||||||
/* check that padding size returned is possible */
|
/* check that padding size returned is possible */
|
||||||
if (wolfSSL_MemoryPaddingSz() < WOLFSSL_STATIC_ALIGN) {
|
if (wolfSSL_MemoryPaddingSz() < WOLFSSL_STATIC_ALIGN) {
|
||||||
return WC_TEST_RET_ENC_NC; /* no room for wc_Memory struct */
|
return WC_TEST_RET_ENC_NC; /* no room for wc_Memory struct */
|
||||||
@@ -17470,7 +17471,9 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void)
|
|||||||
return WC_TEST_RET_ENC_NC; /* should round to 0
|
return WC_TEST_RET_ENC_NC; /* should round to 0
|
||||||
since struct + bucket will not fit */
|
since struct + bucket will not fit */
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
(void)pad;
|
||||||
(void)dist; /* avoid static analysis warning of variable not used */
|
(void)dist; /* avoid static analysis warning of variable not used */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -3102,7 +3102,7 @@ static WC_INLINE void FreeAtomicUser(WOLFSSL* ssl)
|
|||||||
|
|
||||||
#endif /* ATOMIC_USER */
|
#endif /* ATOMIC_USER */
|
||||||
|
|
||||||
#ifdef WOLFSSL_STATIC_MEMORY
|
#if defined(WOLFSSL_STATIC_MEMORY) && !defined(WOLFSSL_LEAN_STATIC_MEMORY)
|
||||||
static WC_INLINE int wolfSSL_PrintStats(WOLFSSL_MEM_STATS* stats)
|
static WC_INLINE int wolfSSL_PrintStats(WOLFSSL_MEM_STATS* stats)
|
||||||
{
|
{
|
||||||
word16 i;
|
word16 i;
|
||||||
|
Reference in New Issue
Block a user