Some windows environments don't have _snprint_s

Do an alternative version for them.
That happens for example with our windows buildbot with mingw32-make.
This commit is contained in:
Manuel Pégourié-Gonnard 2015-07-08 16:46:13 +02:00
parent 6cacde2d57
commit a4f055fe0c
2 changed files with 18 additions and 0 deletions

View File

@ -65,7 +65,16 @@ void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level,
va_start( argp, format );
#if defined(_WIN32)
#if defined(_TRUNCATE)
ret = _vsnprintf_s( str, DEBUG_BUF_SIZE, _TRUNCATE, format, argp );
#else
ret = _vsnprintf( str, DEBUG_BUF_SIZE, format, argp );
if( ret < 0 || (size_t) ret == DEBUG_BUF_SIZE )
{
str[DEBUG_BUF_SIZE-1] = '\0';
ret = -1;
}
#endif
#else
ret = vsnprintf( str, DEBUG_BUF_SIZE, format, argp );
#endif

View File

@ -75,7 +75,16 @@ int mbedtls_platform_win32_snprintf( char *s, size_t n, const char *fmt, ... )
return( -1 );
va_start( argp, fmt );
#if defined(_TRUNCATE)
ret = _vsnprintf_s( s, n, _TRUNCATE, fmt, argp );
#else
ret = _vsnprintf( s, n, fmt, argp );
if( ret < 0 || (size_t) ret == n )
{
s[n-1] = '\0';
ret = -1;
}
#endif
va_end( argp );
return( ret );