diff --git a/examples/client/client.c b/examples/client/client.c index 9aac7cc2f..8950b053a 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -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) diff --git a/wolfssl/wolfcrypt/mem_track.h b/wolfssl/wolfcrypt/mem_track.h index 362ef3969..e76d72083 100644 --- a/wolfssl/wolfcrypt/mem_track.h +++ b/wolfssl/wolfcrypt/mem_track.h @@ -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