From a8cd2e64219d6b2807761ff4f085a54267dfa923 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 17 May 2024 19:00:46 +0200 Subject: [PATCH] Fix the build without check_config.h (inclusion of limits.h) Including `mbedtls/check_config.h` from `mbedtls/config.h` is optional. If done, `limits.h` gets included. If not done, we were missing the inclusion of `limits.h` in several source files. Fix this and add a test build that doesn't include `mbedtls/check_config.h`. Signed-off-by: Gilles Peskine --- ChangeLog.d/build_without_check_config.txt | 3 +++ library/oid.c | 1 + library/psa_crypto_rsa.c | 1 + library/ssl_msg.c | 1 + library/x509_crt.c | 1 + programs/test/udp_proxy.c | 2 ++ tests/scripts/all.sh | 7 +++++++ tests/src/test_helpers/ssl_helpers.c | 2 ++ 8 files changed, 18 insertions(+) create mode 100644 ChangeLog.d/build_without_check_config.txt diff --git a/ChangeLog.d/build_without_check_config.txt b/ChangeLog.d/build_without_check_config.txt new file mode 100644 index 000000000..b7f47667c --- /dev/null +++ b/ChangeLog.d/build_without_check_config.txt @@ -0,0 +1,3 @@ +Bugfix + * Fix the build in some configurations when check_config.h is not included. + Fix #9152. diff --git a/library/oid.c b/library/oid.c index 7d7f1bfda..2868ef94f 100644 --- a/library/oid.c +++ b/library/oid.c @@ -15,6 +15,7 @@ #include "mbedtls/rsa.h" #include "mbedtls/error.h" +#include #include #include diff --git a/library/psa_crypto_rsa.c b/library/psa_crypto_rsa.c index cc3cecafe..3c569b17d 100644 --- a/library/psa_crypto_rsa.c +++ b/library/psa_crypto_rsa.c @@ -16,6 +16,7 @@ #include "psa_crypto_rsa.h" #include "psa_crypto_hash.h" +#include #include #include #include "mbedtls/platform.h" diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 5e8567959..1613a1e6b 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -29,6 +29,7 @@ #include "constant_time_internal.h" #include "mbedtls/constant_time.h" +#include #include #if defined(MBEDTLS_USE_PSA_CRYPTO) diff --git a/library/x509_crt.c b/library/x509_crt.c index a3a4525b9..6728fa0ae 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -26,6 +26,7 @@ #include "mbedtls/oid.h" #include "mbedtls/platform_util.h" +#include #include #if defined(MBEDTLS_PEM_PARSE_C) diff --git a/programs/test/udp_proxy.c b/programs/test/udp_proxy.c index e5b821719..c6e665836 100644 --- a/programs/test/udp_proxy.c +++ b/programs/test/udp_proxy.c @@ -35,6 +35,8 @@ #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ +#include + #if !defined(MBEDTLS_NET_C) int main(void) { diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 01ce3b9c2..c52a69fb5 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -886,6 +886,13 @@ component_test_default_out_of_box () { tests/scripts/run_demos.py } +component_build_without_check_config () { + msg "build: full without check_config.h" + scripts/config.py full + sed -i '/#include.*check_config\.h/ s!^!//!' "$CONFIG_H" + make +} + component_test_default_cmake_gcc_asan () { msg "build: cmake, gcc, ASan" # ~ 1 min 50s CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . diff --git a/tests/src/test_helpers/ssl_helpers.c b/tests/src/test_helpers/ssl_helpers.c index 2359615e5..f919db017 100644 --- a/tests/src/test_helpers/ssl_helpers.c +++ b/tests/src/test_helpers/ssl_helpers.c @@ -10,6 +10,8 @@ #include +#include + #if defined(MBEDTLS_SSL_TLS_C) void mbedtls_test_ssl_log_analyzer(void *ctx, int level,