mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-04-11 23:00:49 +02:00
Stop using MBEDTLS_PRINTF_SIZET
Since Mbed TLS 3.6.0, all officially supported versions of Visual Studio a printf function family that is sufficiently compliant to C99 for our purposes, in particular supporting `%zu` for `size_t`. The only platform without `%zu` that we semi-officially support is older versions of MinGW, still used in our CI. MinGW provides either a Windows legacy printf or a standards-compliant printf depending on the value of `__USE_MINGW_ANSI_STDIO` when compiling each C file. Force the use of the compliant version. Don't rely on `MBEDTLS_PRINTF_SIZET`, which is defined in `<mbedtls/debug.h>` and no longer considers the Windows legacy version in Mbed TLS >= 4.1. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@@ -5,6 +5,15 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
/* On Mingw-w64, force the use of a C99-compliant printf() and friends.
|
||||
* This is necessary on older versions of Mingw and/or Windows runtimes
|
||||
* where snprintf does not always zero-terminate the buffer, and does
|
||||
* not support formats such as "%zu" for size_t and "%lld" for long long.
|
||||
*/
|
||||
#if !defined(__USE_MINGW_ANSI_STDIO)
|
||||
#define __USE_MINGW_ANSI_STDIO 1
|
||||
#endif
|
||||
|
||||
#define MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS
|
||||
|
||||
#include "mbedtls/build_info.h"
|
||||
@@ -441,8 +450,7 @@ int main(int argc, char *argv[])
|
||||
} \
|
||||
} else { \
|
||||
mbedtls_printf("Padding checks only implemented for types of size 2, 4 or 8" \
|
||||
" - cannot check type '" #TYPE "' of size %" MBEDTLS_PRINTF_SIZET \
|
||||
"\n", \
|
||||
" - cannot check type '" #TYPE "' of size %zu\n", \
|
||||
sizeof(TYPE)); \
|
||||
mbedtls_exit(MBEDTLS_EXIT_FAILURE); \
|
||||
} \
|
||||
|
||||
Reference in New Issue
Block a user