Merge pull request #239 from AndrzejKurek/psa-its-file-fixes
Remove a potential call to fwrite with null buffer. Add UBsan testing
This commit is contained in:
commit
c12cb5236b
3 changed files with 10 additions and 7 deletions
|
@ -137,8 +137,8 @@ if(CMAKE_COMPILER_IS_GNU)
|
||||||
set(CMAKE_C_FLAGS_RELEASE "-O2")
|
set(CMAKE_C_FLAGS_RELEASE "-O2")
|
||||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
|
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
|
||||||
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g3 --coverage")
|
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g3 --coverage")
|
||||||
set(CMAKE_C_FLAGS_ASAN "-Werror -fsanitize=address -fno-common -O3")
|
set(CMAKE_C_FLAGS_ASAN "-Werror -fsanitize=address -fno-common -fsanitize=undefined -fno-sanitize-recover=all -O3")
|
||||||
set(CMAKE_C_FLAGS_ASANDBG "-Werror -fsanitize=address -fno-common -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls ")
|
set(CMAKE_C_FLAGS_ASANDBG "-Werror -fsanitize=address -fno-common -fsanitize=undefined -fno-sanitize-recover=all -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls")
|
||||||
set(CMAKE_C_FLAGS_CHECK "-Werror -Os")
|
set(CMAKE_C_FLAGS_CHECK "-Werror -Os")
|
||||||
set(CMAKE_C_FLAGS_CHECKFULL "${CMAKE_C_FLAGS_CHECK} -Wcast-qual")
|
set(CMAKE_C_FLAGS_CHECKFULL "${CMAKE_C_FLAGS_CHECK} -Wcast-qual")
|
||||||
endif(CMAKE_COMPILER_IS_GNU)
|
endif(CMAKE_COMPILER_IS_GNU)
|
||||||
|
@ -149,7 +149,7 @@ if(CMAKE_COMPILER_IS_CLANG)
|
||||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
|
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
|
||||||
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g3 --coverage")
|
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g3 --coverage")
|
||||||
set(CMAKE_C_FLAGS_ASAN "-Werror -fsanitize=address -fno-common -fsanitize=undefined -fno-sanitize-recover=all -O3")
|
set(CMAKE_C_FLAGS_ASAN "-Werror -fsanitize=address -fno-common -fsanitize=undefined -fno-sanitize-recover=all -O3")
|
||||||
set(CMAKE_C_FLAGS_ASANDBG "-Werror -fsanitize=address -fno-common -fsanitize=undefined -fno-sanitize-recover=all -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls ")
|
set(CMAKE_C_FLAGS_ASANDBG "-Werror -fsanitize=address -fno-common -fsanitize=undefined -fno-sanitize-recover=all -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls")
|
||||||
set(CMAKE_C_FLAGS_MEMSAN "-Werror -fsanitize=memory -O3")
|
set(CMAKE_C_FLAGS_MEMSAN "-Werror -fsanitize=memory -O3")
|
||||||
set(CMAKE_C_FLAGS_MEMSANDBG "-Werror -fsanitize=memory -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2")
|
set(CMAKE_C_FLAGS_MEMSANDBG "-Werror -fsanitize=memory -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2")
|
||||||
set(CMAKE_C_FLAGS_CHECK "-Werror -Os")
|
set(CMAKE_C_FLAGS_CHECK "-Werror -Os")
|
||||||
|
|
|
@ -214,9 +214,12 @@ psa_status_t psa_its_set( psa_storage_uid_t uid,
|
||||||
n = fwrite( &header, 1, sizeof( header ), stream );
|
n = fwrite( &header, 1, sizeof( header ), stream );
|
||||||
if( n != sizeof( header ) )
|
if( n != sizeof( header ) )
|
||||||
goto exit;
|
goto exit;
|
||||||
n = fwrite( p_data, 1, data_length, stream );
|
if( data_length != 0 )
|
||||||
if( n != data_length )
|
{
|
||||||
goto exit;
|
n = fwrite( p_data, 1, data_length, stream );
|
||||||
|
if( n != data_length )
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
status = PSA_SUCCESS;
|
status = PSA_SUCCESS;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
|
@ -701,7 +701,7 @@ component_test_no_use_psa_crypto_full_cmake_asan() {
|
||||||
# full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh
|
# full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh
|
||||||
msg "build: cmake, full config + MBEDTLS_USE_PSA_CRYPTO, ASan"
|
msg "build: cmake, full config + MBEDTLS_USE_PSA_CRYPTO, ASan"
|
||||||
scripts/config.pl full
|
scripts/config.pl full
|
||||||
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
|
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||||
scripts/config.pl set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC
|
scripts/config.pl set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC
|
||||||
scripts/config.pl set MBEDTLS_PSA_CRYPTO_C
|
scripts/config.pl set MBEDTLS_PSA_CRYPTO_C
|
||||||
scripts/config.pl unset MBEDTLS_USE_PSA_CRYPTO
|
scripts/config.pl unset MBEDTLS_USE_PSA_CRYPTO
|
||||||
|
|
Loading…
Reference in a new issue