Fix for openssl.test extraction of version and cipher suites. Fix mem tracking to use stderr. Fix client version print to use single printf with newline.

This commit is contained in:
David Garske
2021-10-19 13:00:25 -07:00
parent 7447a567e1
commit dcb2ebba39
2 changed files with 23 additions and 21 deletions

View File

@@ -249,36 +249,38 @@ static int NonBlockingSSL_Connect(WOLFSSL* ssl)
static void ShowCiphers(void) static void ShowCiphers(void)
{ {
static char ciphers[WOLFSSL_CIPHER_LIST_MAX_SIZE]; static char ciphers[WOLFSSL_CIPHER_LIST_MAX_SIZE];
int ret = wolfSSL_get_ciphers(ciphers, (int)sizeof(ciphers)); int ret = wolfSSL_get_ciphers(ciphers, (int)sizeof(ciphers));
if (ret == WOLFSSL_SUCCESS) {
if (ret == WOLFSSL_SUCCESS)
printf("%s\n", ciphers); printf("%s\n", ciphers);
} }
}
/* Shows which versions are valid */ /* Shows which versions are valid */
static void ShowVersions(void) static void ShowVersions(void)
{ {
char verStr[100];
XMEMSET(verStr, 0, sizeof(verStr));
#ifndef NO_OLD_TLS #ifndef NO_OLD_TLS
#ifdef WOLFSSL_ALLOW_SSLV3 #ifdef WOLFSSL_ALLOW_SSLV3
printf("0:"); XSTRNCAT(verStr, "0:", 3);
#endif #endif
#ifdef WOLFSSL_ALLOW_TLSV10 #ifdef WOLFSSL_ALLOW_TLSV10
printf("1:"); XSTRNCAT(verStr, "1:", 3);
#endif #endif
printf("2:"); XSTRNCAT(verStr, "2:", 3);
#endif /* NO_OLD_TLS */ #endif /* NO_OLD_TLS */
#ifndef WOLFSSL_NO_TLS12 #ifndef WOLFSSL_NO_TLS12
printf("3:"); XSTRNCAT(verStr, "3:", 3);
#endif #endif
#ifdef WOLFSSL_TLS13 #ifdef WOLFSSL_TLS13
printf("4:"); XSTRNCAT(verStr, "4:", 3);
#endif #endif
printf("d(downgrade):"); XSTRNCAT(verStr, "d(downgrade):", 14);
#if defined(OPENSSL_EXTRA) || defined(WOLFSSL_EITHER_SIDE) #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_EITHER_SIDE)
printf("e(either):"); XSTRNCAT(verStr, "e(either):", 11);
#endif #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) #if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)

View File

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