Merge pull request #4484 from dgarske/memtest

Fix for openssl test with --enable-memtest (also DH test build edge case)
This commit is contained in:
Sean Parkinson
2021-10-20 08:19:30 +10:00
committed by GitHub
3 changed files with 34 additions and 29 deletions

View File

@@ -249,36 +249,38 @@ static int NonBlockingSSL_Connect(WOLFSSL* ssl)
static void ShowCiphers(void)
{
static char ciphers[WOLFSSL_CIPHER_LIST_MAX_SIZE];
int ret = wolfSSL_get_ciphers(ciphers, (int)sizeof(ciphers));
if (ret == WOLFSSL_SUCCESS)
if (ret == WOLFSSL_SUCCESS) {
printf("%s\n", ciphers);
}
}
/* Shows which versions are valid */
static void ShowVersions(void)
{
char verStr[100];
XMEMSET(verStr, 0, sizeof(verStr));
#ifndef NO_OLD_TLS
#ifdef WOLFSSL_ALLOW_SSLV3
printf("0:");
XSTRNCAT(verStr, "0:", 3);
#endif
#ifdef WOLFSSL_ALLOW_TLSV10
printf("1:");
XSTRNCAT(verStr, "1:", 3);
#endif
printf("2:");
XSTRNCAT(verStr, "2:", 3);
#endif /* NO_OLD_TLS */
#ifndef WOLFSSL_NO_TLS12
printf("3:");
XSTRNCAT(verStr, "3:", 3);
#endif
#ifdef WOLFSSL_TLS13
printf("4:");
XSTRNCAT(verStr, "4:", 3);
#endif
printf("d(downgrade):");
XSTRNCAT(verStr, "d(downgrade):", 14);
#if defined(OPENSSL_EXTRA) || defined(WOLFSSL_EITHER_SIDE)
printf("e(either):");
XSTRNCAT(verStr, "e(either):", 11);
#endif
printf("\n");
/* print all stings at same time on stdout to avoid any flush issues */
printf("%s\n", verStr);
}
#if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)

View File

@@ -11997,16 +11997,19 @@ WOLFSSL_TEST_SUBROUTINE int memory_test(void)
#endif /* !NO_RSA && !NO_ASN */
#endif /* !USE_CERT_BUFFER_* */
#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048) && \
!defined(USE_CERT_BUFFERS_3072) && !defined(USE_CERT_BUFFERS_4096) && \
!defined(NO_ASN)
#ifndef NO_DH
!defined(USE_CERT_BUFFERS_3072) && !defined(USE_CERT_BUFFERS_4096)
#if !defined(NO_ASN) && !defined(NO_DH)
static const char* dhParamsFile = CERT_ROOT "dh2048.der";
#if defined(WOLFSSL_DH_EXTRA) && (!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2)))
static const char* dhKeyFile = CERT_ROOT "statickeys/dh-ffdhe2048.der";
static const char* dhKeyPubFile = CERT_ROOT "statickeys/dh-ffdhe2048-pub.der";
#endif
#endif
#endif
#if !defined(NO_ASN) && !defined(NO_DH)
#if defined(WOLFSSL_DH_EXTRA) && (!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2)))
static const char* dhKeyFile = CERT_ROOT "statickeys/dh-ffdhe2048.der";
static const char* dhKeyPubFile = CERT_ROOT "statickeys/dh-ffdhe2048-pub.der";
#endif
#endif
#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
#ifndef NO_DSA
static const char* dsaKey = CERT_ROOT "dsa2048.der";
#endif

View File

@@ -168,7 +168,7 @@
#ifdef WOLFSSL_DEBUG_MEMORY
#ifdef WOLFSSL_DEBUG_MEMORY_PRINT
printf("Alloc: %p -> %u at %s:%d\n", header->thisMemory, (word32)sz, func, line);
fprintf(stderr, "Alloc: %p -> %u at %s:%d\n", header->thisMemory, (word32)sz, func, line);
#else
(void)func;
(void)line;
@@ -276,7 +276,7 @@
#ifdef WOLFSSL_DEBUG_MEMORY
#ifdef WOLFSSL_DEBUG_MEMORY_PRINT
printf("Free: %p -> %u at %s:%d\n", ptr, (word32)sz, func, line);
fprintf(stderr, "Free: %p -> %u at %s:%d\n", ptr, (word32)sz, func, line);
#else
(void)func;
(void)line;
@@ -337,11 +337,11 @@
ret = wolfSSL_GetAllocators(&mfDefault, &ffDefault, &rfDefault);
if (ret < 0) {
printf("wolfSSL GetAllocators failed to get the defaults\n");
fprintf(stderr, "wolfSSL GetAllocators failed to get the defaults\n");
}
ret = wolfSSL_SetAllocators(TrackMalloc, TrackFree, TrackRealloc);
if (ret < 0) {
printf("wolfSSL SetAllocators failed for track memory\n");
fprintf(stderr, "wolfSSL SetAllocators failed for track memory\n");
return ret;
}
@@ -380,11 +380,11 @@
#endif
#ifdef DO_MEM_STATS
printf("total Allocs = %9ld\n", ourMemStats.totalAllocs);
printf("total Deallocs = %9ld\n", ourMemStats.totalDeallocs);
printf("total Bytes = %9ld\n", ourMemStats.totalBytes);
printf("peak Bytes = %9ld\n", ourMemStats.peakBytes);
printf("current Bytes = %9ld\n", ourMemStats.currentBytes);
fprintf(stderr, "total Allocs = %9ld\n", ourMemStats.totalAllocs);
fprintf(stderr, "total Deallocs = %9ld\n", ourMemStats.totalDeallocs);
fprintf(stderr, "total Bytes = %9ld\n", ourMemStats.totalBytes);
fprintf(stderr, "peak Bytes = %9ld\n", ourMemStats.peakBytes);
fprintf(stderr, "current Bytes = %9ld\n", ourMemStats.currentBytes);
#endif
#ifdef DO_MEM_LIST
@@ -392,7 +392,7 @@
/* print list of allocations */
memHint* header;
for (header = ourMemList.head; header != NULL; header = header->next) {
printf("Leak: Ptr %p, Size %u"
fprintf(stderr, "Leak: Ptr %p, Size %u"
#ifdef WOLFSSL_DEBUG_MEMORY
", Func %s, Line %d"
#endif