From fb91a48616c40cde9ac8819e7708b42be9a38ed0 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 5 Mar 2021 14:17:51 +0000 Subject: [PATCH] Fix memsan build with clang 11 Memsan build was reporting a false positive use of uninitialised memory in x509_crt.c on a struct filled by an _stat function call. According to the man pages, the element reported has to be filled in by the call, so to be safe, and keep memsan happy, zero the struct first. Signed-off-by: Paul Elliott --- ChangeLog.d/fix_memsan_build_clang11.txt | 2 ++ library/x509_crt.c | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 ChangeLog.d/fix_memsan_build_clang11.txt diff --git a/ChangeLog.d/fix_memsan_build_clang11.txt b/ChangeLog.d/fix_memsan_build_clang11.txt new file mode 100644 index 000000000..3f5cc058f --- /dev/null +++ b/ChangeLog.d/fix_memsan_build_clang11.txt @@ -0,0 +1,2 @@ +Changes + * Fix memsan build false positive in x509_crt.c with clang 11 diff --git a/library/x509_crt.c b/library/x509_crt.c index a623c57a6..0aa4f4c21 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -1629,6 +1629,8 @@ cleanup: } #endif /* MBEDTLS_THREADING_C */ + memset( &sb, 0, sizeof( sb ) ); + while( ( entry = readdir( dir ) ) != NULL ) { snp_ret = mbedtls_snprintf( entry_name, sizeof entry_name,