mbedtls icon indicating copy to clipboard operation
mbedtls copied to clipboard

2.28 only: build broken when `check_config.h` is not included

Open gilles-peskine-arm opened this issue 9 months ago • 0 comments

In Mbed TLS 2.x, including mbedtls/check_config.h is optional. We do it in the default configuration file, but users can provide their own configuration file that doesn't include it.

The general philosophy of check_config.h is to have no side effects, but that's not completely true:

  • On Windows (#if defined(_WIN32)), it might define MBEDTLS_PLATFORM_SNPRINTF_ALT and MBEDTLS_PLATFORM_VSNPRINTF_ALT.
  • It includes limits.h.

We need to ensure that these side effects don't matter. They do as of Mbed TLS 2.28.7: at least oid.c uses UINT_MAX but does not include limits.h, which breaks the build when check_config.h is not included. See https://github.com/openthread/openthread/pull/10263#discussion_r1605250367

This is not an issue in Mbed TLS ≥3.0 because there check_config.h has no side effects: the side effects happen in build_info.h.

Almost all of our CI builds (if not all?) include check_config.h. So we might not notice if a build breaks when check_config.h is not included. The goal of this issue is to:

  • Do a build with check_config.h omitted in all.sh.
  • Fix oid.c and any other problem.
  • What about the Windows (v)snprintf alt stuff?

gilles-peskine-arm avatar May 17 '24 16:05 gilles-peskine-arm