mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Merge pull request #3038 from gilles-peskine-arm/align-crypto-programs
Side-port from crypto: programs/
This commit is contained in:
39
tests/configs/config-wrapper-malloc-0-null.h
Normal file
39
tests/configs/config-wrapper-malloc-0-null.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* config.h wrapper that forces calloc(0) to return NULL.
|
||||
* Used for testing.
|
||||
*/
|
||||
/*
|
||||
* Copyright (C) 2019, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
|
||||
#ifndef MBEDTLS_CONFIG_H
|
||||
/* Don't #define MBEDTLS_CONFIG_H, let config.h do it. */
|
||||
|
||||
#include "mbedtls/config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
static inline void *custom_calloc( size_t nmemb, size_t size )
|
||||
{
|
||||
if( nmemb == 0 || size == 0 )
|
||||
return( NULL );
|
||||
return( calloc( nmemb, size ) );
|
||||
}
|
||||
|
||||
#define MBEDTLS_PLATFORM_MEMORY
|
||||
#define MBEDTLS_PLATFORM_STD_CALLOC custom_calloc
|
||||
|
||||
#endif /* MBEDTLS_CONFIG_H */
|
@ -1183,6 +1183,29 @@ component_test_platform_calloc_macro () {
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_malloc_0_null () {
|
||||
msg "build: malloc(0) returns NULL (ASan+UBSan build)"
|
||||
scripts/config.pl full
|
||||
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||
make CC=gcc CFLAGS="'-DMBEDTLS_CONFIG_FILE=\"$PWD/tests/configs/config-wrapper-malloc-0-null.h\"' -O -Werror -Wall -Wextra -fsanitize=address,undefined" LDFLAGS='-fsanitize=address,undefined'
|
||||
|
||||
msg "test: malloc(0) returns NULL (ASan+UBSan build)"
|
||||
make test
|
||||
|
||||
msg "selftest: malloc(0) returns NULL (ASan+UBSan build)"
|
||||
# Just the calloc selftest. "make test" ran the others as part of the
|
||||
# test suites.
|
||||
if_build_succeeded programs/test/selftest calloc
|
||||
|
||||
msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)"
|
||||
# Run a subset of the tests. The choice is a balance between coverage
|
||||
# and time (including time indirectly wasted due to flaky tests).
|
||||
# The current choice is to skip tests whose description includes
|
||||
# "proxy", which is an approximation of skipping tests that use the
|
||||
# UDP proxy, which tend to be slower and flakier.
|
||||
if_build_succeeded tests/ssl-opt.sh -e 'proxy'
|
||||
}
|
||||
|
||||
component_test_make_shared () {
|
||||
msg "build/test: make shared" # ~ 40s
|
||||
make SHARED=1 all check
|
||||
|
@ -65,6 +65,6 @@ check()
|
||||
}
|
||||
|
||||
check scripts/generate_errors.pl library/error.c
|
||||
check scripts/generate_query_config.pl programs/ssl/query_config.c
|
||||
check scripts/generate_query_config.pl programs/test/query_config.c
|
||||
check scripts/generate_features.pl library/version_features.c
|
||||
check scripts/generate_visualc_files.pl visualc/VS2010
|
||||
|
Reference in New Issue
Block a user