Skip to content

Commit 81ea6a6

Browse files
committed
Fix MSVC version guard for C99 format size specifiers
Visual Studio 2013 (_MSC_VER == 1800) doesn't support %zu - only use it on 2015 and above (_MSC_VER >= 1900). %ldd works on Visual Studio 2013, but this patch keeps the two macro definitions together, for simplicity's sake. Signed-off-by: Bence Szépkúti <[email protected]>
1 parent d80553d commit 81ea6a6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Bugfix
2+
* Fix definition of MBEDTLS_PRINTF_SIZET to prevent runtime crashes that
3+
occurred whenever SSL debugging was enabled on a copy of Mbed TLS built
4+
with Visual Studio 2013.
5+
Fixes #10017.

include/mbedtls/debug.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,16 @@
108108
*
109109
* This module provides debugging functions.
110110
*/
111-
#if (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1800)
111+
#if (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1900)
112112
#include <inttypes.h>
113113
#define MBEDTLS_PRINTF_SIZET PRIuPTR
114114
#define MBEDTLS_PRINTF_LONGLONG "I64d"
115115
#else \
116-
/* (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1800) */
116+
/* (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1900) */
117117
#define MBEDTLS_PRINTF_SIZET "zu"
118118
#define MBEDTLS_PRINTF_LONGLONG "lld"
119119
#endif \
120-
/* (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1800) */
120+
/* (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1900) */
121121

122122
#if !defined(MBEDTLS_PRINTF_MS_TIME)
123123
#include <inttypes.h>

0 commit comments

Comments
 (0)