Don't force MBEDTLS_PLATFORM_SNPRINTF_ALT on Windows in check_config.h #3453
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
check_config.h
forcesMBEDTLS_PLATFORM_SNPRINTF_ALT
andMBEDTLS_PLATFORM_VSNPRINTF_ALT
to be defined on Windows. The reason for this is that the native (v)snprintf on older Windows runtimes (up to Visual Studio 2015:_MSVC_VER <= 1900
) does not correctly zero-terminate the buffer. This is documented inplatform.h
and tested inselftest.c
. To work around this bug, the library defines wrappers mbedtls_platform_win32_snprintfand
mbedtls_platform_win32_vsnprintfin
platform.cand uses them as the value of
mbedtls_snprintfand
mbedtls_vsnprintf`.Even if
MBEDTLS_PLATFORM_{V,}SNPRINTF_ALT
is not defined, the macrombedtls_{v,}snprintf
expands to the corresponding wrapper function on platforms where it is necessary. Therefore modifying the configuration to set thexxxSNPRINTF_ALT
symbols is not actually necessary. Don't do it.With this change,
check_config.h
is truly a configuration check, as the name implies, and does not modify the configuration.Here's a CI run with an additional patch that removes the wrapper altogether, to validate that the wrapper is getting used in this pull request: https://jenkins-internal.mbed.com/job/mbedtls-release-new/740/
snprintf
(onlyvsnprintf
). Never mind, the failure of snprintf on mingw shows that we do have a test that would catch the absence of the wrapper if it was necessary.I don't see a need to backport this. The only reason I want to make this change is as a precursor to changing the way
check_config.h
is included, as done in #1999. That would be too disruptive for LTS branches.