Skip to content

Commit

Permalink
Make malloc-0-null a user config file
Browse files Browse the repository at this point in the history
Having a wrapper made it harder to use: incompatible with setting
MBEDTLS_CONFIG_FILE, harder to combine with other settings. It was also
surprising since it was the only test config that was structured in that
way.

Signed-off-by: Gilles Peskine <[email protected]>
  • Loading branch information
gilles-peskine-arm committed Aug 22, 2023
1 parent d4c85af commit 2e70f1c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* config.h wrapper that forces calloc(0) to return NULL.
/* config.h modifier that forces calloc(0) to return NULL.
* Used for testing.
*/
/*
Expand All @@ -18,11 +18,6 @@
* limitations under the License.
*/

#ifndef MBEDTLS_CONFIG_H
/* Don't #define MBEDTLS_CONFIG_H, let config.h do it. */

#include "mbedtls/config.h"

#include <stdlib.h>

#ifndef MBEDTLS_PLATFORM_STD_CALLOC
Expand All @@ -37,5 +32,3 @@ static inline void *custom_calloc(size_t nmemb, size_t size)
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_PLATFORM_STD_CALLOC custom_calloc
#endif

#endif /* MBEDTLS_CONFIG_H */
2 changes: 1 addition & 1 deletion tests/scripts/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2822,7 +2822,7 @@ component_test_platform_calloc_macro () {
component_test_malloc_0_null () {
msg "build: malloc(0) returns NULL (ASan+UBSan build)"
scripts/config.py full
make CC=gcc CFLAGS="'-DMBEDTLS_CONFIG_FILE=\"$PWD/tests/configs/config-wrapper-malloc-0-null.h\"' $ASAN_CFLAGS -O" LDFLAGS="$ASAN_CFLAGS"
make CC=gcc CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"$PWD/tests/configs/user-config-malloc-0-null.h\"' $ASAN_CFLAGS -O" LDFLAGS="$ASAN_CFLAGS"
msg "test: malloc(0) returns NULL (ASan+UBSan build)"
make test
Expand Down

0 comments on commit 2e70f1c

Please sign in to comment.