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 <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2024-05-17 19:00:46 +02:00
parent 2888f05e9a
commit a8cd2e6421
8 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,3 @@
Bugfix
* Fix the build in some configurations when check_config.h is not included.
Fix #9152.

View File

@ -15,6 +15,7 @@
#include "mbedtls/rsa.h"
#include "mbedtls/error.h"
#include <limits.h>
#include <stdio.h>
#include <string.h>

View File

@ -16,6 +16,7 @@
#include "psa_crypto_rsa.h"
#include "psa_crypto_hash.h"
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include "mbedtls/platform.h"

View File

@ -29,6 +29,7 @@
#include "constant_time_internal.h"
#include "mbedtls/constant_time.h"
#include <limits.h>
#include <string.h>
#if defined(MBEDTLS_USE_PSA_CRYPTO)

View File

@ -26,6 +26,7 @@
#include "mbedtls/oid.h"
#include "mbedtls/platform_util.h"
#include <limits.h>
#include <string.h>
#if defined(MBEDTLS_PEM_PARSE_C)

View File

@ -35,6 +35,8 @@
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */
#include <limits.h>
#if !defined(MBEDTLS_NET_C)
int main(void)
{

View File

@ -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 .

View File

@ -10,6 +10,8 @@
#include <test/ssl_helpers.h>
#include <limits.h>
#if defined(MBEDTLS_SSL_TLS_C)
void mbedtls_test_ssl_log_analyzer(void *ctx, int level,