mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-05-11 22:42:23 +02:00
@@ -47,9 +47,13 @@
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#define polarssl_snprintf snprintf
|
||||
#define polarssl_snprintf snprintf
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#endif
|
||||
|
||||
#define DEBUG_BUF_SIZE 512
|
||||
|
||||
static int debug_log_mode = POLARSSL_DEBUG_DFL_MODE;
|
||||
static int debug_threshold = 0;
|
||||
|
||||
@@ -66,17 +70,28 @@ void debug_set_threshold( int threshold )
|
||||
char *debug_fmt( const char *format, ... )
|
||||
{
|
||||
va_list argp;
|
||||
static char str[512];
|
||||
int maxlen = sizeof( str ) - 1;
|
||||
char *str = polarssl_malloc( DEBUG_BUF_SIZE );
|
||||
|
||||
if( str == NULL )
|
||||
return;
|
||||
|
||||
va_start( argp, format );
|
||||
vsnprintf( str, maxlen, format, argp );
|
||||
vsnprintf( str, DEBUG_BUF_SIZE - 1, format, argp );
|
||||
va_end( argp );
|
||||
|
||||
str[maxlen] = '\0';
|
||||
str[DEBUG_BUF_SIZE - 1] = '\0';
|
||||
return( str );
|
||||
}
|
||||
|
||||
void debug_print_msg_free( const ssl_context *ssl, int level,
|
||||
const char *file, int line, char *text )
|
||||
{
|
||||
if( text != NULL )
|
||||
debug_print_msg( ssl, level, file, line, text );
|
||||
|
||||
polarssl_free( text );
|
||||
}
|
||||
|
||||
void debug_print_msg( const ssl_context *ssl, int level,
|
||||
const char *file, int line, const char *text )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user