Exclude macros from query_config.c generation

This commit is contained in:
Andres Amaya Garcia 2019-01-03 20:16:43 +00:00
parent c500ad8cc0
commit 4eb040af4a
2 changed files with 12 additions and 8 deletions

View file

@ -2413,14 +2413,6 @@ int query_config( const char *config )
}
#endif /* MBEDTLS_SSL_COOKIE_TIMEOUT */
#if defined(MBEDTLS_SSL_CIPHERSUITES)
if( strcmp( "MBEDTLS_SSL_CIPHERSUITES", config ) == 0 )
{
MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_CIPHERSUITES );
return( 0 );
}
#endif /* MBEDTLS_SSL_CIPHERSUITES */
#if defined(MBEDTLS_X509_MAX_INTERMEDIATE_CA)
if( strcmp( "MBEDTLS_X509_MAX_INTERMEDIATE_CA", config ) == 0 )
{

View file

@ -23,6 +23,15 @@ my $config_file = "./include/mbedtls/config.h";
my $query_config_format_file = "./scripts/data_files/query_config.fmt";
my $query_config_file = "./programs/ssl/query_config.c";
# Excluded macros from the generated query_config.c. For example, macros that
# have commas or function-like macros cannot be transformed into strings easily
# using the preprocessor, so they should be excluded or the preprocessor will
# throw errors.
my @excluded = qw(
MBEDTLS_SSL_CIPHERSUITES
);
my $excluded_re = join '|', @excluded;
open(CONFIG_FILE, "$config_file") or die "Opening config file '$config_file': $!";
# This variable will contain the string to replace in the CHECK_CONFIG of the
@ -36,6 +45,9 @@ while (my $line = <CONFIG_FILE>) {
# Skip over the macro that prevents multiple inclusion
next if "MBEDTLS_CONFIG_H" eq $name;
# Skip over the macro if it is in the ecluded list
next if $name =~ /$excluded_re/;
$config_check .= "#if defined($name)\n";
$config_check .= " if( strcmp( \"$name\", config ) == 0 )\n";
$config_check .= " {\n";