Wrapper for MSC < VS2015

This commit is contained in:
Eric Blankenhorn
2019-03-08 10:55:34 -06:00
parent be83a54f22
commit d26a6b59a3
2 changed files with 29 additions and 17 deletions

View File

@ -124,11 +124,6 @@ static int loggingEnabled = 0;
static struct log mynewt_log;
#endif /* WOLFSSL_APACHE_MYNEWT */
#ifdef _MSC_VER
/* 4996 warning to use MS extensions e.g., sprintf_s instead of XSPRINTF */
#pragma warning(disable: 4996)
#endif /* _MSC_VER */
#endif /* DEBUG_WOLFSSL */

View File

@ -391,18 +391,35 @@
#endif
#define XSNPRINTF snprintf
#else
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
/* Beginning with the UCRT in Visual Studio 2015 and
Windows 10, snprintf is no longer identical to
_snprintf. The snprintf function behavior is now
C99 standard compliant. */
#define XSNPRINTF snprintf
#else
/* _snprintf only null terminates the string if return len
is less than count */
#define XSNPRINTF _snprintf
#endif
#endif
#ifdef _MSC_VER
#if (_MSC_VER >= 1900)
/* Beginning with the UCRT in Visual Studio 2015 and
Windows 10, snprintf is no longer identical to
_snprintf. The snprintf function behavior is now
C99 standard compliant. */
#define XSNPRINTF snprintf
#else
/* 4996 warning to use MS extensions e.g., _sprintf_s
instead of _snprintf */
#pragma warning(disable: 4996)
static WC_INLINE
int xsnprintf(char *buffer, size_t bufsize,
const char *format, ...) {
va_list ap;
int ret;
if ((int)bufsize <= 0) return -1;
va_start(ap, format);
ret = vsnprintf(buffer, bufsize, format, ap);
if (ret >= (int)bufsize)
ret = -1;
va_end(ap);
return ret;
}
#define XSNPRINTF xsnprintf
#endif /* (_MSC_VER >= 1900) */
#endif /* _MSC_VER */
#endif /* USE_WINDOWS_API */
#if defined(WOLFSSL_CERT_EXT) || defined(HAVE_ALPN)
/* use only Thread Safe version of strtok */